# \`dig\` module through nested list

**URL:** <https://forum.ansible.com/t/dig-module-through-nested-list/29735>\
**Category:** Ansible Project\
**Created:** [February 21, 2019, 4:13pm UTC](https://forum.ansible.com/t/dig-module-through-nested-list/29735 "2019-02-21T16:13:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ashok1](https://avatars.discourse-cdn.com/v4/letter/a/f1d935/32.png) [@Ashok1](https://forum.ansible.com/u/Ashok1)\
**Post date:** [February 21, 2019, 4:13pm UTC](https://forum.ansible.com/t/dig-module-through-nested-list/29735/1 "2019-02-21T16:13:56Z")

</div>

Hi all,

I have a data-structure like the below that consists of few internal hostnames.

client\_groups:  
apache-servers:

- apa01-pco.web.vpn
- apa02-pco.web.vpn
- apa03-pco.web.vpn

mailout:

- mo11-pco.mail.vpn
- mo12-pco.mail.vpn
- mo13-pco.mail.vpn

These are provided in as vars. I’m trying to write a task that uses dig plugin to produce dicts of their respective A records like the below:

client\_groups:

apache-servers:

- ‘10.5.10.111’
- ‘10.2.10.112’
- ‘10.5.10.11’

mailout:

- ‘1.2.3.4’
- ‘5.6.7.8’

So far, I’ve been able to write a task like the below:

_pre\_tasks:_  
_- name: Setting log-client IPs_  
_set\_fact:_  
_ip\_addr: ‘{{ lookup(“dig”, item) }}’_  
_with\_flattened: ‘{{ client\_groups }}’_  
_register: dig\_results_

Please let me know what I am missing. Any hints would be helpful.
