# include when not work

**URL:** <https://forum.ansible.com/t/include-when-not-work/19366>\
**Category:** Ansible Project\
**Created:** [September 28, 2015, 1:46am UTC](https://forum.ansible.com/t/include-when-not-work/19366 "2015-09-28T01:46:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steve\_Kieu1](https://avatars.discourse-cdn.com/v4/letter/s/f05b48/32.png) [@Steve\_Kieu1](https://forum.ansible.com/u/Steve_Kieu1)\
**Post date:** [September 28, 2015, 1:46am UTC](https://forum.ansible.com/t/include-when-not-work/19366/1 "2015-09-28T01:46:17Z")

</div>

Hi team,

I have something like this in my tasks file.

- name: run post sync files  
include: “{{inventory\_dir}}/…/tasks/post-sync-files.yml”  
when: POST\_SYNC\_FILE == ‘yes’

Even the value of POST\_SYNC\_FILE is ‘no’ it still include the yml file and run . Inside the yml file there are bunch of tasks whihc also use when as well but not using the above variables.

Not sure what is wrong with this?

Thanks

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [September 28, 2015, 12:36pm UTC](https://forum.ansible.com/t/include-when-not-work/19366/2 "2015-09-28T12:36:44Z")

</div>

The 'when' is being applied to the included tasks so they should all  
appear as skipped, before 2.0 there is no way to prevent the include  
itself from happening.

---

<div class="post-metadata">

**Author:** ![Steve\_Kieu1](https://avatars.discourse-cdn.com/v4/letter/s/f05b48/32.png) [@Steve\_Kieu1](https://forum.ansible.com/u/Steve_Kieu1)\
**Post date:** [September 28, 2015, 11:14pm UTC](https://forum.ansible.com/t/include-when-not-work/19366/3 "2015-09-28T23:14:53Z")

</div>

I guess it is time to try version 2 then.

Thanks

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [September 28, 2015, 11:33pm UTC](https://forum.ansible.com/t/include-when-not-work/19366/4 "2015-09-28T23:33:55Z")

</div>

the only effective difference is less output
