Help with when clause

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?

when: ‘eth0’ in ansible_interfaces

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

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