# when clause in combination with list of hashes.

**URL:** <https://forum.ansible.com/t/when-clause-in-combination-with-list-of-hashes/15622>\
**Category:** Ansible Project\
**Created:** [July 8, 2014, 8:11am UTC](https://forum.ansible.com/t/when-clause-in-combination-with-list-of-hashes/15622 "2014-07-08T08:11:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nico\_K](https://avatars.discourse-cdn.com/v4/letter/n/46a35a/32.png) [@Nico\_K](https://forum.ansible.com/u/Nico_K)\
**Post date:** [July 8, 2014, 8:11am UTC](https://forum.ansible.com/t/when-clause-in-combination-with-list-of-hashes/15622/1 "2014-07-08T08:11:02Z")

</div>

Hi,

Consider the following list of hashes being defined:

my\_list: [ { src: “a”, dest: “b”, mode: 755 }  
, { src: “d”, dest: “e”, mode: 640 }  
]

and this task:

- name: example  
file:  
path: “{{ item }}”  
state: absent  
with\_items: some\_other\_list  
when: item not in my\_list # (… how to match against ‘src’ ?? )

The ‘when:’ clause in this specific case needs to look at ‘src’ from ‘my\_list’, is there a way to define this?

Thanks,  
Nico.

---

<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:** [July 8, 2014, 11:55am UTC](https://forum.ansible.com/t/when-clause-in-combination-with-list-of-hashes/15622/2 "2014-07-08T11:55:59Z")

</div>

when: item.src not in my\_list
