# tags and role dependencies

**URL:** <https://forum.ansible.com/t/tags-and-role-dependencies/16596>\
**Category:** Ansible Project\
**Created:** [October 24, 2014, 9:29am UTC](https://forum.ansible.com/t/tags-and-role-dependencies/16596 "2014-10-24T09:29:39Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniel\_Wendler](https://avatars.discourse-cdn.com/v4/letter/d/bb73d2/32.png) [@Daniel\_Wendler](https://forum.ansible.com/u/Daniel_Wendler)\
**Post date:** [October 24, 2014, 9:29am UTC](https://forum.ansible.com/t/tags-and-role-dependencies/16596/1 "2014-10-24T09:29:39Z")

</div>

Hello @all,

i have an strage behavior with role dependencies and tags.  
I have an playbook like this:

`

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [October 24, 2014, 12:17pm UTC](https://forum.ansible.com/t/tags-and-role-dependencies/16596/2 "2014-10-24T12:17:46Z")

</div>

For starters, ansible --version output?

---

<div class="post-metadata">

**Author:** ![James\_Cammarata](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@James\_Cammarata](https://forum.ansible.com/u/James_Cammarata)\
**Post date:** [October 24, 2014, 12:40pm UTC](https://forum.ansible.com/t/tags-and-role-dependencies/16596/3 "2014-10-24T12:40:45Z")

</div>

This is happening because you have narrowed the scope of your tags, and the dependent role is only inheriting the “monitoring” tag from its parent role. If you still need to have your deps run when other tags are specified, you can add them to the list of tags on the dependency:

- dependencies:
- { role: monitoring a basics, tags: monitoring:crc }

The same will go for your other tags, which you can add to the list.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [October 24, 2014, 1:12pm UTC](https://forum.ansible.com/t/tags-and-role-dependencies/16596/4 "2014-10-24T13:12:13Z")

</div>

I’m not sure that’s intuitive.

By tagging all things with “monitoring”, everything should get a “monitoring”.

additionally, the included tasks add a “monitoring:crc”

I would expect tags should be additive, and “narrowing the scope of your tags” is not a thing that should be a language concept IMHO.

---

<div class="post-metadata">

**Author:** ![Daniel\_Wendler](https://avatars.discourse-cdn.com/v4/letter/d/bb73d2/32.png) [@Daniel\_Wendler](https://forum.ansible.com/u/Daniel_Wendler)\
**Post date:** [October 24, 2014, 2:17pm UTC](https://forum.ansible.com/t/tags-and-role-dependencies/16596/5 "2014-10-24T14:17:28Z")

</div>

The version is ansible 1.7.2 (1.7.2+dfsg-2~bpo70+1 - installed from distri repo debian wheezy)

Yes, i narrowed the scope of my tag because i want to run only an subset of tasks of the role.  
But as this are tasks in the monitoring role, i was expecting the dependency is triggered an the monitoring-basic role is run anyway.  
I can tag the dependenies also with an whole bunch of tags, but in that case i have to think about it an on every addition in the monitoring role with an other tag  
i also have to adjust the dependency tags.

---

<div class="post-metadata">

**Author:** ![James\_Cammarata](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@James\_Cammarata](https://forum.ansible.com/u/James_Cammarata)\
**Post date:** [October 24, 2014, 4:45pm UTC](https://forum.ansible.com/t/tags-and-role-dependencies/16596/6 "2014-10-24T16:45:36Z")

</div>

Hi Daniel,

Michael and I ran through this and we agree this is operating as expected, since tags applied directly to tasks (like your include statements in tasks/main.yml) are not applied to dependent roles (nor would we expect them to be). So, as I suggested in my reply, you just need to add whatever additional tags may be required to your dependency definitions and you should be good to go.

Let us know if you have any further questions regarding this.

Thanks!

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [October 25, 2014, 12:02am UTC](https://forum.ansible.com/t/tags-and-role-dependencies/16596/7 "2014-10-25T00:02:10Z")

</div>

“since tags applied directly to tasks (like your include statements in tasks/main.yml) are not applied to dependent roles (nor would we expect them to be)”

I may have been confused with the discussion.

I do expect tags like this:

- hosts: webservers  
roles:
- { role: doit, tags: doit }
- { role: other, tags: other }

That dependent roles of “doit” run when you say “doit”.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [October 25, 2014, 12:58am UTC](https://forum.ansible.com/t/tags-and-role-dependencies/16596/8 "2014-10-25T00:58:07Z")

</div>

Ok, communication issue on my end.

“doit” does get applied to everything, and we are good there (no bugs!)

It isn’t true that adding a tag to the “include” statement you have manually inside the role would affect the deps. That would only affect the included tasks in that file.

Sorry for confusion!

---

<div class="post-metadata">

**Author:** ![Daniel\_Wendler](https://avatars.discourse-cdn.com/v4/letter/d/bb73d2/32.png) [@Daniel\_Wendler](https://forum.ansible.com/u/Daniel_Wendler)\
**Post date:** [October 25, 2014, 1:01am UTC](https://forum.ansible.com/t/tags-and-role-dependencies/16596/9 "2014-10-25T01:01:19Z")

</div>

So i think i have to “redesign” my monitoring role to add the tags to the dependency (in meta.yml) or to split the role in multiple roles.

Thanks for your help.
