I’d like to use tags to select tasks I launch.
I found documentations about how to limit playbook, role… execution to the tagged tasks l choose from adhoc command (-t option).
But I need to do the same from another playbook… and I can’t find anything about that
ex :
extract from the main.yml from role “myrole” :
Thanks Matt for your quick answer… Even if it doesn’t arrange me…
It’s weird this is not possible. I’m surprised. I guess I’m not the first one to consider doing this. Is there a reason why ?
Did you (or someone else) hear about a “trick” to get a similar behaviour using something else ?
I finally found a “trick” that made it for me :
Every task in the main.yml from “myrole” are conditioned with a different value for a variable myowntags
ex:
when: myowntags == “fst-openshot”
Then, in a taskfile or playbook, I can select the tasks I want with something like :
name: test
include_role:
name: myrole
vars:
myowntags: “fst-openshot”
As this role is only dedicated to pick up some tasks when needed (not applied to any group as itself), it makes it for me.
Every task in the main.yml from "myrole" are conditioned with a different
value for a variable myowntags
ex:
when: myowntags == "fst-openshot"
Then, in a taskfile or playbook, I can select the tasks I want with
something like :
- name: test
include_role:
name: myrole
vars:
myowntags: "fst-openshot"
As this role is only dedicated to pick up some tasks when needed (not
applied to any group as itself), it makes it for me.
Next option would be to fragment main.yml and put the tasks into
the separate files, e.g
We've seen this requested several times, but it is normally an
indicator of people making plays/roles way too big.
So we recommend actually splitting the playbook/roles into the more
manageable units instead of implementing this kind of functionality or
using a workaround via conditionals.