The quick summary is as follows: the documentation says to think of roles as classes. Complex lifecycle operations are hard to express, decompose, and recompose. This proposal is to extend the use of tags to permit the programmatic selection of tasks from within a playbook. This gives our pseudo-classes something like pseudo-methods.
There’s a sketch of this here, but it probably needs looking at by someone with more in-depth knowledge of the ansible internals: https://github.com/jan-grant/ansible/tree/use-tags
(You use this like this:
- hosts: …
roles: - { role: foo, use_tags: [bar] }
This operates as though “–tags bar” had been specified, only for the role inclusion.)
There are (at least) two projects now that are deploying OpenStack using Ansible. One of the items that came up for discussion at the recent dev summit in Austin was the various patterns used to try to enable the recombination of operations within a role. Currently there are at least two approaches: to explicitly include tasks from a top-level playbook (something that Ansible 2.x breaks); to use something like a run_mode=… variable (eg, the Monasca playbooks do this.)
We’ve already got tags, which can be used to identify logical groupings of tasks; I’m just proposing that Ansible should permit the selection of tags (not just the application of tags) from within playbooks. General consensus at the dev summit was that this was a feature that was typically expected by people coming to Ansible - it’s slightly surprising that it’s missing.
Let me know what you think -
Cheers,
jan