Currently the output of ansible-playbook doesn’t contain any clue about the tags that are being processed.
The can lead to confusion, mostly if a user is developing a playbook which is tag-driven, and forgets to add ‘tags: xyz’ to an action, that action will simply not run and no clue will be given to the user as to why.
It would also be nice to see which tasks are associated with which tags in the output.
Current output:
$ ansible-playbook -c local -tags=“ssh,blahblah” ./setup.yml
PLAY [all] *********************
TASK: [Create directory for mark.] *********************
ok: [localhost]
…
PLAY RECAP *********************
localhost : ok=3 changed=0 unreachable=0 failed=0
Proposed output:
$ ansible-playbook -c local -tags=“ssh,blahblah” ./setup.yml
PLAY [all] *********************
TASK: [ssh] [Create directory for mark.] *********************
ok: [localhost]
…
PLAY RECAP *********************
TAGS
processed : ssh
not found : blahblah
found but skipped : ftp,www
untagged tasks skipped : 4
HOSTS
localhost : ok=3 changed=0 unreachable=0 failed=0
You can see above that the ‘ssh’ tag appears alongside the task output, so that the user knows which tag triggered that task, and if their task names are generic, like for example ‘Create directory’, they can see which tag it’s related to. Instead of naming the task ‘ssh | Create directory’ which is redundant information in the task definition.
Then, in the recap we have:
processed: The tags that had tasks associated with them, and were executed.
not found: Tags that were specified in the execution of the playbook, but no tasks were found with this tag. In the example, there were no tasks associated with ‘blahblah’.
found but skipped: There were actions associated with these tags found in the playbook, however they were skipped because the user did not give the command to run these.
untagged tasks skipped: the total number of tasks with no tags, that were skipped.
I started looking into this, but found that it’s not currently possible to pass the name of the tag down into the Runner. So this makes displaying the tag next to the task difficult without some refactoring.
I’m also looking for some hints of what kind of architecture you would like for something like this, before making it. Should I extend AggregateStats() to support this? That currently fits with per-host stats, not really with playbook stats so I was hesitant. Perhaps a new stats object?
Thanks!
Mark