【发布时间】:2019-06-20 21:04:13
【问题描述】:
我在 Ansible 剧本中有以下内容:
- name: Create certificates directory
file:
dest: "{{ '~/wireguard/certs' | expanduser }}"
state: directory
owner: "{{ ansible_user_id }}"
group: "{{ ansible_user_id }}"
mode: 0700
run_once: true
delegate_to: localhost
但是,当它在 playbook 中运行时,我收到以下错误:
fatal: [1.2.3.4 -> localhost]: FAILED! => {
"changed": false,
"gid": 1000,
"group": "alex",
"mode": "0755",
"msg": "chown failed: [Errno 1] Operation not permitted: b'/home/alex/wireguard'",
"owner": "alex",
"path": "/home/alex/wireguard",
"size": 4096,
"state": "directory",
"uid": 1000
}
我需要以 root 身份运行它还是其他什么?如果我确实需要以 root 身份运行它,become 工作吗?
【问题讨论】: