On 02.02.2019 05:39, Igor Cicimov wrote:
Brian, I find the current usage of "tags" when calling a role via
"roles:"
or "include_role/import_role" is counter intuitive. The reason we tag
tasks
in our playbooks is for the purpose of filtering which we would expect
to
be the case in the above mentioned scenarios as well. But it is not,
and
that is major draw back in making reusable (DRY) code.
I constantly find my self in need to execute just a part of some role
tasks, lets say the ones tagged with "install" but skip the ones tagged
with "configure" lets say. This is exactly what we get by passing
"--tags"
or "--skip-tags" on the command line so why not make this consistent
everywhere?
I would argue that it's very consistent at the moment.
All tags in a yaml file sets/add that tag(s), and which tags you want to
run is specified on the command line.
Use variables if you want to run part of your code.
An example:
roles/test/install.yml
roles/test/configure.yml
roles/test/main.yml
---
- include_tasks: install.yml
when: test_install | default(true) == true
- include_tasks: configure.yml
when: test_configure | default(true) == true
Then to only run install just do this
playbook.yml
- hosts: localhost
roles:
- role: test
test_configure: false
You can also overwrite the variables on the command line too if needed.
--
Kai Stian Olstad
--
You received this message because you are subscribed to the Google Groups "Ansible
Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/3050ca93a2cd5c9f638aa7bbfcaa8e5f%40olstad.com.
For more options, visit https://groups.google.com/d/optout.