Yes, the variable "role_names" contains a list of all role names, as of a
3/11 addition by Brian Coca.

You'll need the development branch.

However in most cases (but not always), it's not needed --- plays are
intended to map groups to roles, so it's intended that tests are applied
against group membership most of the time.

- hosts: webservers
  roles:
     - base
     - webserver
     - monitored

Thus if you were doing an iptables template:

{% if inventory_hostname in groups.webservers %}

Is equivalent to:

{% if 'webserver' in role_names %}

If all machines were to be monitored, it might be nice to even say this:

- host: all
  roles:
    - base

- host: webservers
  roles:
     - webserver

- host: all
  roles:
     - monitored






On Mon, Mar 24, 2014 at 12:17 AM, <[email protected]> wrote:

> Hi.
>
> Is there any way to obtain the list of roles a Host will be playing ?
> Something in the same idea as --list-tasks.
>
> In the same way, being able to list the groups of a host, from outside a
> play (i.e.. at the command line) would be nice (parsing the host file can
> become messy real quick).
>
> Thanks.
> raphael.
>
>
>  --
> 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 [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/18e8ba5b-42a9-4f48-a5fa-d2d88a66ec02%40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/18e8ba5b-42a9-4f48-a5fa-d2d88a66ec02%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAEVJ8QO%2Bea%3DYC3adzptwY9rQe8yXBg1HAtHoN5H3a0238haSUA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to