Roles that don't use tags get ignored

42 views
Skip to first unread message

Giovanni Tirloni

unread,
May 6, 2015, 6:32:16 PM5/6/15
to ansible...@googlegroups.com
Hello,

I developed a series of roles that accept some common tags (e.g.
create, destroy, etc). I also have a "common" role that doesn't make
use of tags, all its tasks should run regardless.

If I specify the roles like this:

---
- hosts: all
roles:
- common
- raid
- lvm
- nic

And run the playbook with `ansible-playbook -i inventory -t create
play.yml`. Then the tasks from common are all ignored, and the other
roles that support the create tag get executed.

After much searching I found the "untagged" tag, and so using "-t
untagged,create" causes the tasks from the common role to run.

Is this the expected behavior? I always that by passing a tag I was
activating something additional, not restricting things that don't have
restrictions (untagged).

Giovanni

Brian Coca

unread,
May 6, 2015, 6:57:27 PM5/6/15
to ansible...@googlegroups.com
No the --tags/-t flag is meant to 'run ONLY these tags', in 1.9 (which
you are using as it also introduced 'untagged') and above you can also
tag the tasks in the common role with 'always' which means it will
always run unless you explicitly --skip-tags always.


--
Brian Coca

Giovanni Tirloni

unread,
May 7, 2015, 7:18:52 AM5/7/15
to ansible...@googlegroups.com
That makes sense, thank you!

Giovanni

Brian Coca

unread,
May 7, 2015, 8:43:27 AM5/7/15
to ansible...@googlegroups.com
actually you can even tag the whole role by passing tags: ['always']
into the role entry in the play so you do not need to do each task.



--
Brian Coca
Reply all
Reply to author
Forward
0 new messages