Mac 在 Ansible 中使用复制模块时出现权限问题
Permissions issue when using copy module in Ansible on Mac
我正在 Mac OS X v10.11.6 上从 Ansible v2.2.1 运行 中的角色尝试执行以下任务,但我遇到了权限问题(复制如下) :
- name: Create the test scripts
copy:
src: "usr_bin_{{item}}"
dest: "/usr/bin/{{item}}"
owner: root
group: wheel
mode: 0755
with_items: ["abc", "def", "ghi"]
become: true
become_method: sudo
become_user: root
错误
failed: [localhost] (item=abc) => {"checksum": "44b300f4a9334ca0e34d0e5b3e2c121c76214f7c", "failed": true, "item": "abc", "msg": "Destination /usr/bin not writable"}
failed: [localhost] (item=def) => {"checksum": "dcd44e71b93f303c5d9abfcecd48c8637eabeeaa", "failed": true, "item": "def", "msg": "Destination /usr/bin not writable"}
failed: [localhost] (item=ghi) => {"checksum": "b9c28df8772702ba9b4b7d05e24c972aa536bdc3", "failed": true, "item": "ghi", "msg": "Destination /usr/bin not writable"}
您不能在 OS X / macOS 上自由写入 /usr/bin
(自 El Capitan 起)- 了解 System Integrity Protection。
通常的做法是用/usr/local/bin
代替,但需要加到PATH
。请注意,Homebrew 包管理器假定(默认情况下)/usr/local
的子目录应该可由普通用户写入,而不是 root
.
我正在 Mac OS X v10.11.6 上从 Ansible v2.2.1 运行 中的角色尝试执行以下任务,但我遇到了权限问题(复制如下) :
- name: Create the test scripts
copy:
src: "usr_bin_{{item}}"
dest: "/usr/bin/{{item}}"
owner: root
group: wheel
mode: 0755
with_items: ["abc", "def", "ghi"]
become: true
become_method: sudo
become_user: root
错误
failed: [localhost] (item=abc) => {"checksum": "44b300f4a9334ca0e34d0e5b3e2c121c76214f7c", "failed": true, "item": "abc", "msg": "Destination /usr/bin not writable"}
failed: [localhost] (item=def) => {"checksum": "dcd44e71b93f303c5d9abfcecd48c8637eabeeaa", "failed": true, "item": "def", "msg": "Destination /usr/bin not writable"}
failed: [localhost] (item=ghi) => {"checksum": "b9c28df8772702ba9b4b7d05e24c972aa536bdc3", "failed": true, "item": "ghi", "msg": "Destination /usr/bin not writable"}
您不能在 OS X / macOS 上自由写入 /usr/bin
(自 El Capitan 起)- 了解 System Integrity Protection。
通常的做法是用/usr/local/bin
代替,但需要加到PATH
。请注意,Homebrew 包管理器假定(默认情况下)/usr/local
的子目录应该可由普通用户写入,而不是 root
.