conditional include

49 views
Skip to first unread message

Yves Dorfsman

unread,
Feb 21, 2013, 11:33:40 AM2/21/13
to ansible...@googlegroups.com

Would it be possible to add conditional includes?

I have playbooks to install an apps. I play those in different environments
(acceptance, production, etc...), and some products included need to be
installed only in some of the environement. Here's an example:


---

- include: ../logistics/logistics-tomcat.playbook.yaml

- include: ../logistics/logistics-oracle.playbook.yaml

- include: ../logistics/logistics-splunk.playbook.yaml
vars_files:
- ../vars/main.vars.yaml
when_string: $env == PRODUCTION


--
Yves. http://www.SollerS.ca/
Unix/Linux and Python specialist in Calgary.
http://blog.zioup.org/

Daniel Hokka Zakrisson

unread,
Feb 21, 2013, 11:39:28 AM2/21/13
to ansible...@googlegroups.com
Yves Dorfsman wrote:
>
> Would it be possible to add conditional includes?
>
> I have playbooks to install an apps. I play those in different
> environments
> (acceptance, production, etc...), and some products included need to be
> installed only in some of the environement. Here's an example:

Sounds exactly like what groups and hosts: is for. Why would you have nodes
in your splunk group that aren't supposed to have it installed? If, for some
reason you do, hosts: splunk:&environment works to limit the play to nodes
in both those groups.

Conditionals do work on task includes, but not on playbook includes right
now, primarily because plays already have hosts: to decide which nodes to
run on.

Daniel

> ---
>
> - include: ../logistics/logistics-tomcat.playbook.yaml
>
> - include: ../logistics/logistics-oracle.playbook.yaml
>
> - include: ../logistics/logistics-splunk.playbook.yaml
> vars_files:
> - ../vars/main.vars.yaml
> when_string: $env == PRODUCTION
>
>
> --
> Yves.
> http://www.SollerS.ca/
> Unix/Linux and Python specialist in
> Calgary.
> http://blog.zioup.org/
>
> --
> 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.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Reply all
Reply to author
Forward
0 new messages