Joshua Gilman
Joshua Gilman

Reputation: 1202

Ansible pause between task invocation on host

I have three Consul servers that need to have their configuration reloaded after changes have been made. It's important that the reload process has a delay between each host in order to keep the cluster healthy. The number of servers is dynamic and determined by a group that is dynamically built. Example:

---
- hosts: ConsulServer
  tasks:
    - name: Reload configuration
      ansible.builtin.shell: consul reload

Running the above playbook would result in Ansible executing the reload command against each host with little to no pause between each invocation. How can I force Ansible to slow down how quickly it runs the task against each host?

Upvotes: 0

Views: 816

Answers (1)

Joshua Gilman
Joshua Gilman

Reputation: 1202

This is by no means what I would consider the "best" answer since it's only applicable if you're using the shell module like myself, however, it does meet the original requirement.

---
- hosts: ConsulServer
  tasks:
    - name: Reload configuration
      ansible.builtin.shell: consul reload && sleep 10
      throttle: 1

Upvotes: 1

Related Questions