Hi guys,
I wonder if anyone knows if it’s possible do use the ‘in’ clause with a list of dicts.
I have a list that looks like this:
[{u’state’: None, u’id’: u’i-233b31yy’}, {u’state’: None, u’id’: u’i-2a2281xx’}]
I want to add_host if an id is not in the list, something like:
`
vars:
mylist:
- {u’state’: None, u’id’: u’i-233b31yy’}
- {u’state’: None, u’id’: u’i-2a2281xx’}
tasks:
local_action:
module: add_host
name: “{{ ansible_ec2_local_ipv4 }}”
group: not_in_elb
when: ansible_ec2_instance_id not in mylist
`
The above fails because the list items are dicts. How can I just look at the id value of each dict in the list?