Hi,
all. I have review some similar topic on task reusability of ansible role and task execute order. But i still cannot get an answer to my problem. here it is:
suppose i have a role named ‘service_a’, and I have write a set of tasks in ‘service_a/tasks/tasks.yml’, such like this:
service_a/tasks/tasks.yml
- name: open the door
… - name: get mails from mailbox
… - name: turn on the light
…
Now, I want to organize those actions in different orders, as below (just some fake code to explain my needs):
service_a/tasks/main.yml
-
name: get mails then open the door, because mail box is outside the room
tasks: -
“get mails from mailbox”
-
“open the door”
-
“turn on the light”
…
tags: mailbox_outside_the_room -
name: open the door then get mails, because mail box is inside the room
tasks: -
“open the door”
-
“turn on the light”
-
“get mails from mailbox”
…
tags: mailbox_inside_the_room
How to implements like this? Can any Help?