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?
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:
import_role
tasks instead of the roles
sectionFor 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. 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