Hi all,
I think I am not the only one who is being confused by how tags on
roles work:
- roles:
- { role: xyz, tags: 'whatever'}
This does *not* call only the parts of the role that are tagged
'whatever', instead all tasks in this role are being tagged whatever
and are being called.
Is there any way to just run the parts of a role that are having a
certain tag?
One workaround would be to add a certain variable to the role call,
and just run the task in the role when this variable has the right
value. But how to do that?
Thanks in advance,
Johannes
I have seen others ask for this. Hopefully, there will eventually be a more elegant method. However, I believe that the only way to do this is, as you said, use a variable. I do this for debug or testing tasks that I don’t want to run normally, but if I pass -e ‘{“run_tests”:true}’ when I run the playbook they will execute.
#roles/stuff/tasks/main.yml
`
Hi Mike,
I have seen others ask for this. Hopefully, there will eventually be a more
elegant method.
Does ansible have a bugtracker/wishlist other than the github issues?
I'll have to check that...
However, I believe that the only way to do this is, as you
said, use a variable. I do this for debug or testing tasks that I don't
want to run normally, but if I pass -e '{"run_tests":true}' when I run the
playbook they will execute.
Thanks for confirmation, than that's the way to go for me.
Johannes