playbook pause and tag madness!

Hi all,

Sorry for the rant but I get through this and think that with that matter ansible is quirky.

  1. 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.

  1. 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.

It is a mess!

cat update-php.yml

Ironically If I remove the tags: [‘install-php’] in the role and then it behaves better that it only play that tags.

Again it still skip the pause for not any reason.

Steve,

Hi,

(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

/Martin

​Well, it's YAML, and YAML translates that to a dictionary, and a
dictionary is not ordered...​

There are limits to simplicity.

I’m not talking about the underlying technical spec just that I understand the expectations of the OP.

Maybe a solution would be to put this information somewhere in the documentation where it is more visible?

regards,

Martin

​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.

Might be a helpful patch on

     http://docs.ansible.com/playbooks_roles.html#roles
and/or
     http://docs.ansible.com/YAMLSyntax.html

    Serge