当我运行我的剧本时,我收到一条错误,提示'destination/etc not writable'
:
fatal: [B-mmp-edge-90c9.stg01.aws.company.net]: FAILED! => {"changed": false, "checksum": "686f224b9b97fe890014e1320f48d31cae90abc2", "msg": "Destination /etc not writable"}
fatal: [B-mmp-edge-9df4.stg01.aws.company.net]: FAILED! => {"changed": false, "checksum": "23cd3c17b1f9f84d48dc67affd5d3f4e09506b48", "msg": "Destination /etc not writable"}
我的剧本common.yml
里面只有这个:
---
- hosts: all, !ansible
roles:
- common
在roles/common/meta/main.yml
中我有:
---
dependencies:
- { role: selinux_disable }
# - { role: iptables_disable }
- { role: motd }
- { role: ntp }
# - { role: epel }
# - { role: hosts }
- { role: users }
# - { role: limits }
# - { role: sysctl }
- { role: snmp }
我使用的是 Ansible 版本 2.6.4。
我想我需要有 root 权限。但我不知道如何在 Ansible 角色中做到这一点。有人可以帮忙吗?
最佳答案
要使用 root 权限执行 Ansible 任务,您需要添加以下内容:
name: YourPlaybookName
hosts: YourHosts
become: yes
请注意第三行和 become: yes
指令。
有关 Ansible 中权限提升的更多信息,请查看:https://docs.ansible.com/ansible/latest/user_guide/become.html
关于Ansible 目的地/等不可写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60213251/