# Problem when use with\_items, groups and include with Ansible 1.2.2

**URL:** <https://forum.ansible.com/t/problem-when-use-with-items-groups-and-include-with-ansible-1-2-2/13236>\
**Category:** Ansible Project\
**Created:** [August 1, 2013, 9:14am UTC](https://forum.ansible.com/t/problem-when-use-with-items-groups-and-include-with-ansible-1-2-2/13236 "2013-08-01T09:14:34Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![judauphant](https://avatars.discourse-cdn.com/v4/letter/j/ce73a5/32.png) [@judauphant](https://forum.ansible.com/u/judauphant)\
**Post date:** [August 1, 2013, 9:14am UTC](https://forum.ansible.com/t/problem-when-use-with-items-groups-and-include-with-ansible-1-2-2/13236/1 "2013-08-01T09:14:34Z")

</div>

Hi guys,

I have a error when I run this playbook with Ansible:

---

<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 1, 2013, 10:48pm UTC](https://forum.ansible.com/t/problem-when-use-with-items-groups-and-include-with-ansible-1-2-2/13236/2 "2013-08-01T22:48:52Z")

</div>

So a lot of the with\_items handling is a LOT better in 1.3

I believe 1.2.X (don’t remember offhand) probably wants you to evaluate the expression:

with\_items: “{{ groups[‘foo’] }}”

whereas in 1.3 I know the following is fine:

with\_items: groups[‘foo’]

---

<div class="post-metadata">

**Author:** ![judauphant](https://avatars.discourse-cdn.com/v4/letter/j/ce73a5/32.png) [@judauphant](https://forum.ansible.com/u/judauphant)\
**Post date:** [August 2, 2013, 3:05pm UTC](https://forum.ansible.com/t/problem-when-use-with-items-groups-and-include-with-ansible-1-2-2/13236/3 "2013-08-02T15:05:26Z")

</div>

Thanks for your answer Michael,

I have try on 1.2.2 and 1.3 ( with the last commit on github on devel branch )  
with\_items: “{{ groups[‘jails’] }}”  
I have still the same error :  
ERROR: with\_items expects a list

In 1.3 with  
with\_items: groups[‘jails’]  
Same error :  
ERROR: with\_items expects a list

With other action like “debug”, I have no problem, both form works but with not with “include”.

Best regards,  
Julien

---

<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 2, 2013, 3:27pm UTC](https://forum.ansible.com/t/problem-when-use-with-items-groups-and-include-with-ansible-1-2-2/13236/4 "2013-08-02T15:27:17Z")

</div>

A) You really should use 1.3 if you want to pass lists like this, it works much better.

B) Don’t use “{{ }}” in with\_items in 1.3, totally not needed:

with\_items: groups[‘jails’]

---

<div class="post-metadata">

**Author:** ![judauphant](https://avatars.discourse-cdn.com/v4/letter/j/ce73a5/32.png) [@judauphant](https://forum.ansible.com/u/judauphant)\
**Post date:** [August 2, 2013, 4:08pm UTC](https://forum.ansible.com/t/problem-when-use-with-items-groups-and-include-with-ansible-1-2-2/13236/5 "2013-08-02T16:08:28Z")

</div>

A) Ok, I keep the 1.3 version

B) I have the same problem with 1.3 when “with\_items” is use with “include” action

---

<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 2, 2013, 4:54pm UTC](https://forum.ansible.com/t/problem-when-use-with-items-groups-and-include-with-ansible-1-2-2/13236/6 "2013-08-02T16:54:06Z")

</div>

include + with\_items is not supported and definitely doesn’t work with non-global variables.

(I should just remove it at this point.)

---

<div class="post-metadata">

**Author:** ![judauphant](https://avatars.discourse-cdn.com/v4/letter/j/ce73a5/32.png) [@judauphant](https://forum.ansible.com/u/judauphant)\
**Post date:** [August 2, 2013, 5:29pm UTC](https://forum.ansible.com/t/problem-when-use-with-items-groups-and-include-with-ansible-1-2-2/13236/7 "2013-08-02T17:29:00Z")

</div>

Thank you Michael,

I have change my implementation, I use a global variable now, it more flexible in the futur for me now.

---

<div class="post-metadata">

**Author:** ![Serge\_van\_Ginderacht](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Serge\_van\_Ginderacht](https://forum.ansible.com/u/Serge_van_Ginderacht)\
**Post date:** [August 2, 2013, 5:31pm UTC](https://forum.ansible.com/t/problem-when-use-with-items-groups-and-include-with-ansible-1-2-2/13236/8 "2013-08-02T17:31:43Z")

</div>

​​Please leave that as a very hidden feature for those that know what they  
do :)​

---

<div class="post-metadata">

**Author:** ![judauphant](https://avatars.discourse-cdn.com/v4/letter/j/ce73a5/32.png) [@judauphant](https://forum.ansible.com/u/judauphant)\
**Post date:** [August 4, 2013, 12:39am UTC](https://forum.ansible.com/t/problem-when-use-with-items-groups-and-include-with-ansible-1-2-2/13236/9 "2013-08-04T00:39:27Z")

</div>

Variable declared in “group\_vars/all” and “host\_vars/my\_host” are non-global variables ?  
Because It’s doesn’t work neither with include + with\_items .

---

<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 4, 2013, 2:11am UTC](https://forum.ansible.com/t/problem-when-use-with-items-groups-and-include-with-ansible-1-2-2/13236/10 "2013-08-04T02:11:00Z")

</div>

they are inventory variables.

Seriously, don’t use with\_items + include together. Loop inside the task files instead.
