iterate over an array of dicts: find and register one of them

I have an array of dicts that came from the dnsmadeeasy module. I need to find the spf record.

The SPF record is a TXT record that begins ‘v=spf1’ and then continues on. I need to get the record, modify it, and put it back. I’m not worried about modifying it.

To get the record, I think I have to do this:

`

On way would be to use this new method that works a bit like the jq tool:

http://docs.ansible.com/ansible/playbooks_filters.html#json-query-filter

I discovered this recently and it was pretty handy for munging nested data structures.

A loop using with_subelements could work too:

http://docs.ansible.com/ansible/playbooks_loops.html#looping-over-subelements

you can do most things with filters

(not tested)

  • set_fact: myvar=“{{ response | map(attribute=‘value’) | list }}”