1

Here is my playbook:

---
- hosts: "mms"
  user: wladmin

  roles:
    - { role: App1 }
    - { role: App2 }
    - { role: App3 }
    - { role: App4 }

I wish to put pause of 30 seconds between these ansible roles.

I tried the below but it give me syntax error:

  roles:
    - { role: App1 }
  pause:
    seconds: 30
    - { role: App2 }
  pause:
    seconds: 30
    - { role: App3 }

I also tried

  roles:
    - { role: App1 }
    - pause:
        seconds: 30
    - { role: App2 }
    - pause:
       seconds: 30
    - { role: App3 }

Can you please suggest?

Ashar
  • 2,942
  • 10
  • 58
  • 122

1 Answers1

5

pause isn't a role, so you can't include it in the roles section of your play. pause is a task. You have a couple of options:

Use import_role tasks instead of the roles section

For example:

- hosts: localhost
  tasks:
    - import_role:
        name: App1
    - pause:
        seconds: 30
    - import_role:
        name: App2
    - pause:
        seconds: 30
    - import_role:
        name: App3

Create a "pause" role

Create a pause role. Put this in roles/pause/tasks/main.yml:

- name: pause
  pause:
    seconds: "{{ pause_seconds|default(30) }}"

And this in roles/pause/meta/main.yml:

allow_duplicates: true

Now you can write:

- hosts: localhost
  roles:
    - App1
    - pause
    - App2
    - pause
    - App3
larsks
  • 277,717
  • 41
  • 399
  • 399