代码之家  ›  专栏  ›  技术社区  ›  The HCD

确保ansible with_序列循环中的延迟

  •  0
  • The HCD  · 技术社区  · 7 年前

    - 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 }}
    

    这是否足以在重新启动实例_1后暂停5秒, 然后在实例2之后5秒 等

    1 回复  |  直到 7 年前
        1
  •  2
  •   Konstantin Suvorov    7 年前

    使用 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