我正在使用 ansible 在 25 台服务器上禁用 selinux。
- name: disable selinux
selinux: state=disabled
服务器在主机文件中定义,我正在运行剧本
ansible-playbook -v -i hosts ansible/server-prepare.yml
输出如下所示:
GATHERING FACTS ***************************************************************
ok: [10.0.0.10]
(... other servers ...)
TASK: [prepare | disable selinux] *********************************************
changed: [10.0.0.10] => {"changed": true, "configfile": "/etc/selinux/config", "msg": "state change will take effect next reboot", "policy": "targeted", "state": "disabled"}
(... other servers ...)
但是,主机 10.0.0.10 上的配置文件中的值并未更改:
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=enforcing
我知道,更改配置文件后需要重新启动,但配置文件根本没有更改。 对于 playbook 中的所有命令,ansible 返回成功,但没有任何效果。
目前,我只尝试将 -v
添加到 ansible-playbook
命令中。我还有其他选项来调试这个吗?我正在使用 ansible-playbook 1.9.2
。
最佳答案
为了测试我添加了:
connection: local
这导致对本地主机进行更改,即使 ansible 报告在其他 ip 上运行。
关于Ansible playbook 不更改文件,但返回成功,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31721750/