# Conditional include

**URL:** <https://forum.ansible.com/t/conditional-include/13292>\
**Category:** Ansible Project\
**Created:** [August 13, 2013, 5:59pm UTC](https://forum.ansible.com/t/conditional-include/13292 "2013-08-13T17:59:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![howachen](https://avatars.discourse-cdn.com/v4/letter/h/54ee81/32.png) [@howachen](https://forum.ansible.com/u/howachen)\
**Post date:** [August 13, 2013, 5:59pm UTC](https://forum.ansible.com/t/conditional-include/13292/1 "2013-08-13T17:59:25Z")

</div>

I want to mass include .yml files under the tasks folder when a condition is met, something like

- include:
- foo.yml
- bar.yml  
when: ansible\_os\_family == “Debian”

Is it possible currently?

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [August 13, 2013, 6:21pm UTC](https://forum.ansible.com/t/conditional-include/13292/2 "2013-08-13T18:21:45Z")

</div>

no, includes are not conditional.

what that does is add the condition to each task in the includes.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [August 13, 2013, 7:16pm UTC](https://forum.ansible.com/t/conditional-include/13292/3 "2013-08-13T19:16:48Z")

</div>

So it’s basically the same thing in the end 🙂

Note that this behavior is improved in 1.3, where if you have any conditions they are inserted before any conditions in the task.

I also highly recommend the group\_by module for conditional application of roles.
