确保 ansible with_sequence 循环中的延迟 [英] ensuring a delay in an ansible with_sequence loop

查看:22
本文介绍了确保 ansible with_sequence 循环中的延迟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下正确调用的处理程序,但是,所有序列似乎都在快速连续运行.我想以指定的延迟一个一个地运行.这行得通吗?

I've the following handler that is invoked correctly, however, all the sequences appear to be run in quick succession. I'd like to run one by one with a specified delay. will this work?

- name: 'restart process_server_x_instance_y'
  shell: '/bin/restarter serverx_instance_{{item}}'
  ignore_errors: yes
  delay: 5
  with_sequence: count={{ number_of_instances|length }}

这足以在重新启动 instance_1 后暂停 5 秒,然后在 instance_2 之后 5 秒等?

is this enough to pause 5secs after restarting instance_1, then 5 secs after instance_2 etc?

推荐答案

Use loop_control - pause:

- name: 'restart process_server_x_instance_y'
  shell: '/bin/restarter serverx_instance_{{item}}'
  ignore_errors: yes
  with_sequence: count={{ number_of_instances|length }}
  loop_control:
    pause: 5

这篇关于确保 ansible with_sequence 循环中的延迟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆