Role dependencies

21 views
Skip to first unread message

Ferdinand Svehla

unread,
Sep 20, 2016, 2:32:41 PM9/20/16
to Ansible Project
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?

Dick Davies

unread,
Sep 21, 2016, 3:42:36 AM9/21/16
to ansible list
I've used role dependencies to address a similar requirement (collectd
in our case).

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:

---
dependencies:
- { role: telegraf }
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-proje...@googlegroups.com.
> To post to this group, send email to ansible...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/4673802a-da95-4bc4-9c53-ac33c4bc1860%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages