# conditional include

**URL:** <https://forum.ansible.com/t/conditional-include/12400>\
**Category:** Ansible Project\
**Created:** [February 21, 2013, 4:33pm UTC](https://forum.ansible.com/t/conditional-include/12400 "2013-02-21T16:33:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yves\_Dorfsman](https://avatars.discourse-cdn.com/v4/letter/y/9de0a6/32.png) [@Yves\_Dorfsman](https://forum.ansible.com/u/Yves_Dorfsman)\
**Post date:** [February 21, 2013, 4:33pm UTC](https://forum.ansible.com/t/conditional-include/12400/1 "2013-02-21T16:33:40Z")

</div>

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:

---

<div class="post-metadata">

**Author:** ![Daniel\_Hokka\_Zakriss](https://avatars.discourse-cdn.com/v4/letter/d/f05b48/32.png) [@Daniel\_Hokka\_Zakriss](https://forum.ansible.com/u/Daniel_Hokka_Zakriss)\
**Post date:** [February 21, 2013, 4:39pm UTC](https://forum.ansible.com/t/conditional-include/12400/2 "2013-02-21T16:39:28Z")

</div>

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
