Ansible:当我禁用防火墙时,状态始终显示已更改
我尝试使用ansible禁用Centos7上的防火墙。 这项工作:Ansible:当我禁用防火墙时,状态始终显示已更改,ansible,centos7,firewall,Ansible,Centos7,Firewall,我尝试使用ansible禁用Centos7上的防火墙。 这项工作: - name: turn off firewall for install command: systemctl disable firewalld become: yes 但我必须多次重新运行此ansible playbook,每次输出都显示“已更改”,而我希望它是“正常”” 我错过了什么或做错了什么? 谢谢尝试使用模块,而不是使用命令,例如: - name: turn off firewall for
- name: turn off firewall for install
command: systemctl disable firewalld
become: yes
但我必须多次重新运行此ansible playbook,每次输出都显示“已更改”
,而我希望它是“正常”
”
我错过了什么或做错了什么?
谢谢尝试使用模块,而不是使用命令
,例如:
- name: turn off firewall for install
systemd:
name: firewalld
state: stopped
enabled: false
发件人:
当shell/命令或其他模块运行时,它通常会根据是否认为它影响了机器状态来报告“已更改”状态
要覆盖“已更改”结果,使其不会出现在报告输出中或不会导致处理程序触发,可以尝试以下操作:
- name: turn off firewall for install
command: systemctl disable firewalld
become: yes
changed_when: False
- name: turn off firewall for install
command: systemctl disable firewalld
become: yes
changed_when: False