本文介绍了确保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_2etc?

推荐答案

使用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循环中的延迟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 18:57