Thanks a lot Kai,
On 08/24/2018 04:31 PM, Kai Stian Olstad wrote:
On Friday, 24 August 2018 15.47.39 CEST Frank Thommen wrote:
since "recently" (we realized just now), tags applied in role's main.yml
task, like:
/role/myrole/tasks/main.yml:
- name: My Task
include_tasks: "mytask.{{ansible_osfamily}}.yml"
tags:
- mytask-only
- always
are not propagated to the included task any more.
<skip />
However this is a major pain for us: We are extensively using unified,
role-spanning[*] tags on the level of the the main tasks to be able to
selectively roll out our configurations. The new behaviour means, that
we have to manually add hundreds(!) of "tag" statements to each
individual task in all the included taskfiles.
You don't need to add it to every task, you can use a block: around them all
and set the tag on the block.
You can also wrap the include_tasks in a block, and set the tags on the block.
- block:
- name: My Task
include_tasks: "mytask.{{ansible_osfamily}}.yml"
tags:
- mytask-only
- always
Very nice solution. I myself experimendet with a construction like:
- name: "My Task"
block:
- import_tasks: mytask.RedHat.yml
when: distro == "RedHat"
- import_tasks: mytask.CentOS.yml
when: distro == "CentOS"
- import_tasks: mytask.Suse.yml
when: distro == "Suse"
- import_tasks: mytask.Debian.yml
when: distro == "Debian"
tags:
- mytask-only
which makes for bad reading and bad maintainability. Your idea with the
block is elegant and well maintainable while keeping all the dynamic and
flexibility.
I realize blocks are more versatile than I thought ;-)
f.
Is there a way to achieve the former behaviour (tag inheritance to
dynamic includes) other than framing each task.yml with a block, which
introduces redundancy and error-proneness?
Only the workaround mention above, but you can always downgrade.
There are some discussion don't remember if it was in an issue or on this list
about a option or something like that to tell if it should propagate or not.
--
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/b16843c0-2a9b-318f-57c0-2c46ac009146%40drosera.ch.
For more options, visit https://groups.google.com/d/optout.