AIR
AIR

Reputation: 825

How to add ansible loop with wait?

I am new in ansible where I want to start cassandra services in all my nodes with 2/3 minutes apart. I have host file as:

[dc1]
dc1-node0 ansible_host=10.1.0.1
dc1-node1 ansible_host=10.1.0.2
dc1-node2 ansible_host=10.1.0.2
[dc2]
dc2-node ansible_host=10.2.0.1
dc2-node1 ansible_host=10.2.0.2
dc2-node2 ansible_host=10.2.0.2

At present, I am executing it manually:

ansible -a "service dse start" dc1-node0

... and so on with 2 mins apart.

I want to create a playbook for the same.

Please advice.

Upvotes: 0

Views: 1725

Answers (1)

Konstantin Suvorov
Konstantin Suvorov

Reputation: 68269

User serial and pause:

---
- hosts: all
  serial: 1
  tasks:
    - service:
        name: dse
        state: started
    - pause:
        minutes: 2 

Upvotes: 1

Related Questions