Sorry for the rant but I get through this and think that with that matter ansible is quirky.
First roles with tags not work as expected (yes saw some post and people saying you need to agg at the command line
My play book like this
name: ctn
hosts: staging-web
roles:
{ role: web_base, tags: [‘install-php’] }
It executed who whole role no matter the tags is there.
Task and Roles unexpected behaviour.
Example I have
name: DO something
hosts: myhost
tasks:
pause:
roles:
web_base
If doing like this the tasks and pause is not executed. The role is executed and I did not wait until role finsihed to see if the task is touched at all.
So I have to split them like this, but why do I need to?
name: do something
hosts: myhost
task:
pause:
name: ditto
hosts: myhost
roles:
myrole
Now it is not enough. The that playbook if I play without the options tags=XXX then it prompts me. But with teh option --tags=XXX then it does not pause me anymore, Why the --tags option affect how the playbook order of execution?
See be low is my playbook and if play without --tag=install-php then it prompts me to warn, But if I specified the tag it skip the prompt (pause) but then play everything rather than only this tags.
(Now this is just a theoretical point. Actually changing that stuff would probably break too much existing stuff)
actually I think there’s a point to the pre_task,roles,post_task stuff.
It makes perfect sense once you found that section in the docs, on the other hand one of the big promises of ansible is simplicity and (to me) a big point here is that the following seems reasonable and should just work:
typing on a cell but you get the idea (hopefully)
name: play
tasks:
debug:
msg: this runs first
roles:
{role_that_runs_second}
tasks:
debug:
msg: this runs last
Agreed, it might help to explain that the order in which you write the
different tasks blocks, don't affect the execution order. Same for all
yaml keys.