我正在尝试我的行动手册中的以下任务。但是不执行暂停。我希望在删除每个主机后,播放应该暂停一次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: 120
ignore_error: yes
with_items:
- "{{ groups['grp1'] }}"有人可以建议这是正确的方式,如果做或建议我的正确方式。我也使用了serial=1模块,但它仍然不能工作。
发布于 2018-05-16 01:00:44
你可以在你的循环下使用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发布于 2018-05-15 22:22:19
不幸的是,目前在Ansible中不可能对with_items应用多个任务,但在include directive中仍然可以做到。举个例子,
主播放文件将是
---
- hosts: localhost
connection: local
gather_facts: no
remote_user: me
tasks:
- include: sub_play.yml nagios_host={{ item }}
with_items:
- host1
- host2
- host3包括在主播中的sub_play yml将是,
---
- shell: echo "{{ nagios_host }}"
- pause:
prompt: "Waiting for {{ nagios_host }}"
seconds: 5在本例中,include语句通过一个循环执行,该循环执行sub_task yml中的所有任务。
https://stackoverflow.com/questions/50347298
复制相似问题