In Ansible 1.7, I can use --tags from the command-line to only run a subset of that playbooks tasks.
But I'm wanting to bake into my playbook to run a set of roles with only tasks that match tags. That is, I don't want to have to pass this in via the command-line since it will be the same every time.
At first I thought it was this command, but this does the opposite: tagging tasks with these tags instead of filtering them out based on this.
roles: - { role: webserver, port: 5000, tags: [ 'web', 'foo' ] }
I can imagine implementing this using conditionals but tags would be a much more elegant way of achieving this.
If you assign the always tag to a task or play, Ansible will always run that task or play, unless you specifically skip it ( --skip-tags always ). Fact gathering is tagged with 'always' by default. It is only skipped if you apply a tag and then use a different tag in --tags or the same tag in --skip-tags .
Roles provide a framework for fully independent, or interdependent collections of variables, tasks, files, templates, and modules. In Ansible, the role is the primary mechanism for breaking a playbook into multiple files. This simplifies writing complex playbooks, and it makes them easier to reuse.
Ansible has a well-known mechanism to only run a certain list of tasks: tags. When we call ansible-playbook with the --tags parameter, we only execute tasks that have one of the specified tasks. There is also a --skip-tags option, which runs all tasks except those with the specified tags.
You only have the following options with the current version of Ansible:
This feature request has come up on the mailing list a few times and I haven't seen any indication from the dev team that it will be added as a new feature.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With