"you cannot execute a role conditionally, you CAN pass a condition to every
task in a role."

True!

- { role:  asdf, when: foo == 'asdf' }

Another good trick is group_by is a great way to create a small group of
hosts where a given condition is true or false, and then you just apply
that role to that group.

- hosts: all
  tasks:
      - group_by: key=foo_{{ foo }}

# talk to all hosts where the value of foo is asdf
- hosts: foo_asdf
  roles:
     - asdf





On Thu, Jul 10, 2014 at 7:26 AM, Brian Coca <[email protected]> wrote:

> you cannot execute a role conditionally, you CAN pass a condition to every
> task in a role.
>
> role and include directives are basically 'preprocessing macros' they are
> used to include other files into main play.
> ​
>
> --
> 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/CADn%2BHsz6YvdjD1QvrKAP-Pg_yE%2BOmeFKEgAeMGJXVVcy6_oZ-Q%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CADn%2BHsz6YvdjD1QvrKAP-Pg_yE%2BOmeFKEgAeMGJXVVcy6_oZ-Q%40mail.gmail.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/CA%2BnsWgz2jVy-S%3DDK7NHWty7OV%2BZf2bgr9%2Bgx1Am3qTMrHA504g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to