I have the following scenario, and I just want to see if I understand correctly what is happening (hopefully after posting this my alignment doesn’t get all messed up):
main.yml <---- Gathers some variables… has some includes based on those variables
/
true.yml false.yml <— Try to utilize variables called in main.yml
\ /
common_tasks.yml
Questions:
-
When setting variables in main.yml, and can I utilize those variables outside of main? Such as when I include true|false.yml files and try to utilize them in there? I don’t know if setting them within main limits their scope.
-
Say I have servers A B C D and E. If A B C are evaluated as true, and the true.yml is included, and the D E servers resolve as false, is my order of execution as follows?
-
Execute main.yml
-
Execute true.yml (listed first in main.yml) for all servers: A B C D E, but apply the “when: condition” listed in the main.yml to all servers
-
Execute the common_tasks.yml for all servers (no condition tied to the common.yml include) as it is in the bottom of the true.yml
-
Execute false.yml for all servers, but apply the “when: condition” listed in the main.yml to all servers
-
Execute the common_tasks.yml for all servers again (as it is listed in the bottom of the false.yml too)?
The above is my guess as to how this is going to want to operate, but I haven’t confirmed it completely yet. If that is the case, how can I call the common_tasks.yml just once after true/false.yml files are executed?