# Role dependencies

**URL:** <https://forum.ansible.com/t/role-dependencies/22591>\
**Category:** Ansible Project\
**Created:** [September 20, 2016, 9:26am UTC](https://forum.ansible.com/t/role-dependencies/22591 "2016-09-20T09:26:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ferdinand\_Svehla](https://avatars.discourse-cdn.com/v4/letter/f/8c91f0/32.png) [@Ferdinand\_Svehla](https://forum.ansible.com/u/Ferdinand_Svehla)\
**Post date:** [September 20, 2016, 9:26am UTC](https://forum.ansible.com/t/role-dependencies/22591/1 "2016-09-20T09:26:45Z")

</div>

I am using the roles + site.yml recommended setup.  
Most, but not all boxes run telegraf (a stats collector), which is defined as an inventory group as a (tagged) role in site.yml.

In my Redis role, if the current host has the telegraf role I’d like to add a file a folder (so Telegraf will pick it up) and refresh the telegraf service.  
Here is where it gets tricky - I would basically call out to a different role - what is the way to do this in Ansible?

---

<div class="post-metadata">

**Author:** ![Dick\_Davies](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@Dick\_Davies](https://forum.ansible.com/u/Dick_Davies)\
**Post date:** [September 21, 2016, 7:42am UTC](https://forum.ansible.com/t/role-dependencies/22591/2 "2016-09-21T07:42:16Z")

</div>

I've used role dependencies to address a similar requirement (collectd  
in our case).

[http://docs.ansible.com/ansible/playbooks\_roles.html#role-dependencies](http://docs.ansible.com/ansible/playbooks_roles.html#role-dependencies)

If you make the telegraf role a dependency of the redis role, you'll  
have access to vars  
set by the telegraf role as well as its handlers by the time the redis  
role runs.

you just a need a file roles/redis/meta/main.yml that looks like this:
