run only selected tags

43 views
Skip to first unread message

Denis J. Cirulis

unread,
Feb 5, 2015, 8:26:37 AM2/5/15
to ansible...@googlegroups.com
Hello,

As I composed one role which partially can be reused in some others I tried the following syntax in playbook:

hosts: test
sudo: True
roles:
  - common
  - { role: big, tags: [ 'aaa', 'bbb' ]}

But looks like tags functionality is not working. If I run playbook with --tags arg it runs only matching tags, but when I want to list all tags to execute in roles it runs the whole role.

How can I overcome this ?

Giovanni Tirloni

unread,
Feb 5, 2015, 9:33:25 AM2/5/15
to ansible...@googlegroups.com
Sorry, perhaps I didn't get it. Can you clarify? The --tags option is
used to limit which tags are considered.

You want to *list* all the tags contained in a given playbook? I don't
think there is an option for that.

Giovanni

Timothy Gerla

unread,
Feb 5, 2015, 9:49:04 AM2/5/15
to ansible-project
This doesn't mean "run tasks tagged aaa and bbb in role big", it means "tag all of role big with tags aaa and bbb". This is so you can have a playbook that calls certain roles conditionally, based on the tags you're executing.

If you find yourself trying to call parts of a role, I would suggest breaking that role up into smaller roles and calling those as needed. The point of a role is to be a single useful set of tasks that is executed as a group, so if your roles are not decomposed enough, you will probably have trouble.

Hope this helps!

-Tim
 

Denis J. Cirulis

unread,
Feb 5, 2015, 10:11:21 AM2/5/15
to ansible...@googlegroups.com
Thanks Timothy, that's exactly what I was thinking of. Will just decompose the role into smaller sets of tasks and that's all.
Just saw in ansible documentation that:

You may also apply tags to roles:

roles:
  - { role: webserver, port: 5000, tags: [ 'web', 'foo' ] }
and thought it will execute tasks by tags :)


четверг, 5 февраля 2015 г., 16:49:04 UTC+2 пользователь Timothy Gerla написал:
Reply all
Reply to author
Forward
0 new messages