# Role Dependencies - Only Run Tag of Dependent Role

**URL:** <https://forum.ansible.com/t/role-dependencies-only-run-tag-of-dependent-role/18660>\
**Category:** Ansible Project\
**Created:** [July 2, 2015, 1:46pm UTC](https://forum.ansible.com/t/role-dependencies-only-run-tag-of-dependent-role/18660 "2015-07-02T13:46:21Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jacob\_Seeley](https://avatars.discourse-cdn.com/v4/letter/j/b77776/32.png) [@Jacob\_Seeley](https://forum.ansible.com/u/Jacob_Seeley)\
**Post date:** [July 2, 2015, 1:46pm UTC](https://forum.ansible.com/t/role-dependencies-only-run-tag-of-dependent-role/18660/1 "2015-07-02T13:46:21Z")

</div>

Hello,

I’d like to have one role be dependent upon another role’s tag only. Here is what I am trying:

# meta/main.yml

---

<div class="post-metadata">

**Author:** ![Strahinja\_Kustudic2](https://avatars.discourse-cdn.com/v4/letter/s/b4bc9f/32.png) [@Strahinja\_Kustudic2](https://forum.ansible.com/u/Strahinja_Kustudic2)\
**Post date:** [July 2, 2015, 1:52pm UTC](https://forum.ansible.com/t/role-dependencies-only-run-tag-of-dependent-role/18660/2 "2015-07-02T13:52:27Z")

</div>

Ansible doesn’t support role dependency using tags. Tags are only used for executing specific tasks which can be passes from the command line.

To do what you want, you would have to define a variable in the other\_role and set a when: clause on all tasks when that variable is true, or set.

---

<div class="post-metadata">

**Author:** ![Jacob\_Seeley](https://avatars.discourse-cdn.com/v4/letter/j/b77776/32.png) [@Jacob\_Seeley](https://forum.ansible.com/u/Jacob_Seeley)\
**Post date:** [July 2, 2015, 2:15pm UTC](https://forum.ansible.com/t/role-dependencies-only-run-tag-of-dependent-role/18660/3 "2015-07-02T14:15:54Z")

</div>

That’s unfortunate. That would require me to set variables in all tasks on _other\_role_ that I would not have otherwise set, just so that I can pass a variable that triggers one task in _other\_role_.

---

<div class="post-metadata">

**Author:** ![Strahinja\_Kustudic2](https://avatars.discourse-cdn.com/v4/letter/s/b4bc9f/32.png) [@Strahinja\_Kustudic2](https://forum.ansible.com/u/Strahinja_Kustudic2)\
**Post date:** [July 2, 2015, 2:17pm UTC](https://forum.ansible.com/t/role-dependencies-only-run-tag-of-dependent-role/18660/4 "2015-07-02T14:17:42Z")

</div>

What you could do is group those task into a separate yml file and then include them in the main.yml:

`  
include: some\_var\_tasks.yml  
when: some\_var

`

---

<div class="post-metadata">

**Author:** ![Jacob\_Seeley](https://avatars.discourse-cdn.com/v4/letter/j/b77776/32.png) [@Jacob\_Seeley](https://forum.ansible.com/u/Jacob_Seeley)\
**Post date:** [July 2, 2015, 2:26pm UTC](https://forum.ansible.com/t/role-dependencies-only-run-tag-of-dependent-role/18660/5 "2015-07-02T14:26:23Z")

</div>

Well, I’m already doing that inside _other\_role_; however, I’m guessing if I make _other\_role_ a dependency of this other role and pass _some\_var_, it’s still going to try to execute all other tasks in _other\_role_, including all other ones defined in their own yml and included in _other\_role_ main.yml

Unless you’re suggesting I somehow include this yml file that exists in _other\_role_ in the main.yml of the role that is dependent upon this task.

And to be clear, I’m trying to make this happen so that I don’t have to recreate this task in this other role.

---

<div class="post-metadata">

**Author:** ![Strahinja\_Kustudic2](https://avatars.discourse-cdn.com/v4/letter/s/b4bc9f/32.png) [@Strahinja\_Kustudic2](https://forum.ansible.com/u/Strahinja_Kustudic2)\
**Post date:** [July 2, 2015, 2:39pm UTC](https://forum.ansible.com/t/role-dependencies-only-run-tag-of-dependent-role/18660/6 "2015-07-02T14:39:53Z")

</div>

I think I lost you now. If you could give us the role structure, dependencies and what you would like to achieve, I think it will be easier to help you out.

---

<div class="post-metadata">

**Author:** ![Jacob\_Seeley](https://avatars.discourse-cdn.com/v4/letter/j/b77776/32.png) [@Jacob\_Seeley](https://forum.ansible.com/u/Jacob_Seeley)\
**Post date:** [July 2, 2015, 3:06pm UTC](https://forum.ansible.com/t/role-dependencies-only-run-tag-of-dependent-role/18660/7 "2015-07-02T15:06:10Z")

</div>

I was afraid of that. I’ll start fresh.

role1/  
├── files  
├── handlers  
│ └── main.yml  
├── meta  
│ └── main.yml  
└── tasks  
├── task1.yml  
├── task2.yml  
├── main.yml  
└── task3.yml

role2/  
├── files  
├── handlers  
│ └── main.yml  
├── meta  
│ └── main.yml  
└── tasks  
├── task1.yml  
├── task2.yml  
├── main.yml  
└── task3.yml

# role2/meta/main.yml
