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 ?
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
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.
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
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