# Combining with\_items with "when:".

**URL:** <https://forum.ansible.com/t/combining-with-items-with-when/12813>\
**Category:** Ansible Project\
**Tags:** ansible-project\
**Created:** [May 16, 2013, 1:17pm UTC](https://forum.ansible.com/t/combining-with-items-with-when/12813 "2013-05-16T13:17:09Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lester\_Wade](https://avatars.discourse-cdn.com/v4/letter/l/97f17d/32.png) [@Lester\_Wade](https://forum.ansible.com/u/Lester_Wade)\
**Post date:** [May 16, 2013, 1:17pm UTC](https://forum.ansible.com/t/combining-with-items-with-when/12813/1 "2013-05-16T13:17:09Z")

</div>

Tried encapsulating it in " "?

when: {{ omgeving }} == “{{ europort.environment }}”

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [May 16, 2013, 1:24pm UTC](https://forum.ansible.com/t/combining-with-items-with-when/12813/2 "2013-05-16T13:24:23Z")

</div>

That advice is not it, Lester, as you can see from his above message that the variable didn’t expand.

The problem is that you have defined “europort” as a list of a single item that contains a hash, rather than a normal hash.

Try this:

---

<div class="post-metadata">

**Author:** ![Mark\_Maas](https://avatars.discourse-cdn.com/v4/letter/m/7c8e57/32.png) [@Mark\_Maas](https://forum.ansible.com/u/Mark_Maas)\
**Post date:** [May 16, 2013, 2:44pm UTC](https://forum.ansible.com/t/combining-with-items-with-when/12813/3 "2013-05-16T14:44:00Z")

</div>

Ah ok, but how do I manage multiple items then Like they way I have it now:

europort:

- environment: eptm  
epuser: eepletm  
orasid: EPTM  
changenr: 02940328  
version: “0508”  
patches: “02”

- environment: ept1  
epuser: eeplet1  
orasid: EPT1  
changenr: 02940328  
version: “0508”  
patches: “02,04”

- environment: ept2  
epuser: eeplet2  
orasid: EPT2  
changenr: 086940328  
version: “0509”  
patches: “09,10,11”

- environment: ept4  
epuser: eeplet4  
orasid: EPT89  
changenr: 029sdsd328  
version: “0508”  
patches: “001,01,02”

---

<div class="post-metadata">

**Author:** ![kahlil.hodgson](https://avatars.discourse-cdn.com/v4/letter/k/b9bd4f/32.png) [@kahlil.hodgson](https://forum.ansible.com/u/kahlil.hodgson)\
**Post date:** [May 16, 2013, 10:17pm UTC](https://forum.ansible.com/t/combining-with-items-with-when/12813/4 "2013-05-16T22:17:34Z")

</div>

I think the syntax you are looking for is:

when: omgeving == item.environment  
with\_items: europort

---

<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:** [May 16, 2013, 10:34pm UTC](https://forum.ansible.com/t/combining-with-items-with-when/12813/5 "2013-05-16T22:34:53Z")

</div>

yes!

---

<div class="post-metadata">

**Author:** ![Mark\_Maas](https://avatars.discourse-cdn.com/v4/letter/m/7c8e57/32.png) [@Mark\_Maas](https://forum.ansible.com/u/Mark_Maas)\
**Post date:** [May 17, 2013, 5:11am UTC](https://forum.ansible.com/t/combining-with-items-with-when/12813/6 "2013-05-17T05:11:31Z")

</div>

THANK YOU!

That was the exact “fix”.
