# when condition not being evaluated with include statement

**URL:** <https://forum.ansible.com/t/when-condition-not-being-evaluated-with-include-statement/15978>\
**Category:** Ansible Project\
**Created:** [August 18, 2014, 11:20am UTC](https://forum.ansible.com/t/when-condition-not-being-evaluated-with-include-statement/15978 "2014-08-18T11:20:06Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Imran\_Khan1](https://avatars.discourse-cdn.com/v4/letter/i/a4c791/32.png) [@Imran\_Khan1](https://forum.ansible.com/u/Imran_Khan1)\
**Post date:** [August 18, 2014, 11:20am UTC](https://forum.ansible.com/t/when-condition-not-being-evaluated-with-include-statement/15978/1 "2014-08-18T11:20:06Z")

</div>

I have a tikitaka3.yml (main yml file) and a tikitaka3a.yml (playbook to be included) . When I prompt the user for a variable and then in the tasks section when I call it, like so:

---

<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 18, 2014, 11:44am UTC](https://forum.ansible.com/t/when-condition-not-being-evaluated-with-include-statement/15978/2 "2014-08-18T11:44:14Z")

</div>

The when does not affect the include itself, it gets added to all tasks included.​

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [August 18, 2014, 12:36pm UTC](https://forum.ansible.com/t/when-condition-not-being-evaluated-with-include-statement/15978/3 "2014-08-18T12:36:15Z")

</div>

Take a look at the docs of the “group\_by” module if you want some more elegant output based on dynamic criteria.

---

<div class="post-metadata">

**Author:** ![Imran\_Khan1](https://avatars.discourse-cdn.com/v4/letter/i/a4c791/32.png) [@Imran\_Khan1](https://forum.ansible.com/u/Imran_Khan1)\
**Post date:** [August 18, 2014, 12:42pm UTC](https://forum.ansible.com/t/when-condition-not-being-evaluated-with-include-statement/15978/4 "2014-08-18T12:42:26Z")

</div>

Then what can I do to achieve the functionality that I require?

---

<div class="post-metadata">

**Author:** ![Imran\_Khan1](https://avatars.discourse-cdn.com/v4/letter/i/a4c791/32.png) [@Imran\_Khan1](https://forum.ansible.com/u/Imran_Khan1)\
**Post date:** [August 18, 2014, 12:51pm UTC](https://forum.ansible.com/t/when-condition-not-being-evaluated-with-include-statement/15978/5 "2014-08-18T12:51:50Z")

</div>

Basically I want to run my secondary playbook on a specific number of hosts in a specific group (I have shown just one example of a group here i.e. umar, I intend on having three groups) using var\_prompts, the group is going to be specified in my main file whereas the logic for particular host selection will reside in each of the 3 secondary playbooks for example the user wants to modify the first 3 nodes (from a total of 15) in the group named umar

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [August 18, 2014, 2:01pm UTC](https://forum.ansible.com/t/when-condition-not-being-evaluated-with-include-statement/15978/6 "2014-08-18T14:01:45Z")

</div>

The group\_by module?

---

<div class="post-metadata">

**Author:** ![Imran\_Khan1](https://avatars.discourse-cdn.com/v4/letter/i/a4c791/32.png) [@Imran\_Khan1](https://forum.ansible.com/u/Imran_Khan1)\
**Post date:** [August 19, 2014, 7:49am UTC](https://forum.ansible.com/t/when-condition-not-being-evaluated-with-include-statement/15978/7 "2014-08-19T07:49:11Z")

</div>

Well, I think I will just make a predefined number of groups such as EPC1, EPC2 and EPC4 (each containing 1,2 or 4 EPCs) , similarly do the same for CLIENTS and SERVERS and tell the user to modify the hosts at the start of a play book such as

- hosts: SERVER1:EPC2:CLIENTS4

This is very inefficient, but I don’t know what to do. Can the group-by module do something similar without having to do something that is so inefficient
