Ansible资源清册中主机之间的暂停时间
我正在我的剧本中尝试下面的任务。但暂停没有执行。我想在删除每台主机后,播放应该暂停30秒Ansible资源清册中主机之间的暂停时间,ansible,pause,ansible-inventory,Ansible,Pause,Ansible Inventory,我正在我的剧本中尝试下面的任务。但暂停没有执行。我想在删除每台主机后,播放应该暂停30秒 name: delete host from the NagiosXI shell: curl -k -XDELETE "https://10.000.00.00/nagiosxi/api/v1/config/host?apikey=qdjcwc&pretty=1&host_name={{ item }}&applyconfig=1" - pause: seconds:
name: delete host from the NagiosXI
shell: curl -k -XDELETE "https://10.000.00.00/nagiosxi/api/v1/config/host?apikey=qdjcwc&pretty=1&host_name={{ item }}&applyconfig=1"
- pause:
seconds: 120
ignore_error: yes
with_items:
- "{{ groups['grp1'] }}"
有人能建议这是否是正确的方式,如果做或建议我正确的方式。我也使用了serial=1模块,但它仍然不起作用。不幸的是,在Ansible中目前无法将多个任务应用于with_项,但使用
include指令仍然可行。例如,
主播放文件将是
---
- hosts: localhost
connection: local
gather_facts: no
remote_user: me
tasks:
- include: sub_play.yml nagios_host={{ item }}
with_items:
- host1
- host2
- host3
主剧本中包含的副剧本yml是
---
- shell: echo "{{ nagios_host }}"
- pause:
prompt: "Waiting for {{ nagios_host }}"
seconds: 5
在这种情况下,include语句通过一个循环执行,该循环执行子任务yml中的所有任务。您可以在循环下使用pause:
- name: Pause
hosts: all
gather_facts: False
tasks:
- name: delete host from the NagiosXI
shell: curl -k -XDELETE "https://10.000.00.00/nagiosxi/api/v1/config/host?apikey=qdjcwc&pretty=1&host_name={{ item }}&applyconfig=1"
ignore_errors: True
with_items:
- "{{ groups['grp1'] }}"
loop_control:
pause: 120
我经常这样做。我认为它就像一个函数调用。:)如果您打算使用shell
curl
无论如何,您可以curl$all$your$args&&sleep 120
。