xre*_*ref 8 selinux ansible ansible-playbook
我在运行一个完整的剧本时遇到了麻烦,因为后来播放的某些事实依赖于在早期剧本中被修改,但是ansible不会在中期更新事实.
运行ansible somehost -m setup时,整个剧本开始对新的VPS:
"ansible_selinux": {
"status": "disabled"
},
Run Code Online (Sandbox Code Playgroud)
我的剧本包含一个安装SELinux并重新启动服务器的游戏(同时是ansible wait_for),后面的任务使用条件when: ansible_selinux.status != 'disabled'.但是,即使SELinux现在已安装并执行(需要重新启动),系统的事实仍会显示SELinux已禁用,因此条件失败并跳过任务.
再次运行剧本当然有效,因为事实已更新并现在返回:
"ansible_selinux": {
"config_mode": "enforcing",
"mode": "enforcing",
"policyvers": 28,
"status": "enabled",
"type": "targeted"
}
Run Code Online (Sandbox Code Playgroud)
有没有办法让事实刷新中期剧本?也许黑客是set_fact在重启后自己在ansible_selinux.status上?
更新:这太简单了,感谢BruceP我在SELinux游戏结束时添加了这个任务以获取更新的事实
- name: SELinux - Force ansible to regather facts
setup: filter='ansible_selinux'
Run Code Online (Sandbox Code Playgroud)
des*_*ing 13
在您的剧本中添加此内容以使用设置模块更新事实.
例如,我添加了另一个与DHCP的接口,现在我想知道它有什么地址然后执行此操作:
- name: do facts module to get latest information
setup:
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5726 次 |
| 最近记录: |