# Help with when clause

**URL:** <https://forum.ansible.com/t/help-with-when-clause/13273>\
**Category:** Ansible Project\
**Created:** [August 8, 2013, 3:58pm UTC](https://forum.ansible.com/t/help-with-when-clause/13273 "2013-08-08T15:58:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rishi](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@Rishi](https://forum.ansible.com/u/Rishi)\
**Post date:** [August 8, 2013, 3:58pm UTC](https://forum.ansible.com/t/help-with-when-clause/13273/1 "2013-08-08T15:58:49Z")

</div>

I am trying to create a task that will only run when a certain network card is on the box. I have multiple ethernet interface per box, I am trying to basically do:

for eth in eth\_interfaces:  
if module == ‘drivername’

Is this possible? Or should I run a command to find the info and store the result to be used as the conditional?

---

<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:** [August 8, 2013, 4:18pm UTC](https://forum.ansible.com/t/help-with-when-clause/13273/2 "2013-08-08T16:18:23Z")

</div>

when: ‘eth0’ in ansible\_interfaces

---

<div class="post-metadata">

**Author:** ![Rishi](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@Rishi](https://forum.ansible.com/u/Rishi)\
**Post date:** [August 8, 2013, 4:58pm UTC](https://forum.ansible.com/t/help-with-when-clause/13273/3 "2013-08-08T16:58:51Z")

</div>

I want to be conditional on the ‘module’ field inside ansible\_eth\* object.

So basically run a task if module == ‘intel’ is true in either ansible\_eth0, ansible\_eth1 etc…

in pseudo code:

when: ‘intel’ in ansible\_eth\*.module

---

<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 8, 2013, 7:38pm UTC](https://forum.ansible.com/t/help-with-when-clause/13273/4 "2013-08-08T19:38:57Z")

</div>

There may be cleaner ways, but you can take advantage of the “map” filter in Jinja2 as listed here:

[http://jinja.pocoo.org/docs/templates/#builtin-filters](http://jinja.pocoo.org/docs/templates/#builtin-filters)
