# dig lookup multiple hosts

**URL:** <https://forum.ansible.com/t/dig-lookup-multiple-hosts/29205>\
**Category:** Ansible Project\
**Created:** [December 5, 2018, 6:55pm UTC](https://forum.ansible.com/t/dig-lookup-multiple-hosts/29205 "2018-12-05T18:55:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rjwagner.dba](https://avatars.discourse-cdn.com/v4/letter/r/e8c25b/32.png) [@rjwagner.dba](https://forum.ansible.com/u/rjwagner.dba)\
**Post date:** [December 5, 2018, 6:55pm UTC](https://forum.ansible.com/t/dig-lookup-multiple-hosts/29205/1 "2018-12-05T18:55:46Z")

</div>

Hey all - I’m trying to lookup the IPs for a list of FQDNs. The dig lookup is close to what I need, but it appears to return a list of IPs for a single FQDN; when using with\_items, it yields each of the IPs for that FQDN ([https://docs.ansible.com/ansible/2.5/plugins/lookup/dig.html](https://docs.ansible.com/ansible/2.5/plugins/lookup/dig.html)). Any idea how I can use with\_items to iterate over the list of FQDNs and store the resulting list of IPs?

Something sort of like:

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [December 5, 2018, 8:08pm UTC](https://forum.ansible.com/t/dig-lookup-multiple-hosts/29205/2 "2018-12-05T20:08:20Z")

</div>

I'm might misunderstand you question, but if you turn it around I think get your answer

&nbsp;&nbsp;- debug: msg='IP for {{ item }} is {{ lookup('dig', item) }}'  
&nbsp;&nbsp;&nbsp;&nbsp;with\_items: "{{ db\_hosts }}"

---

<div class="post-metadata">

**Author:** ![rjwagner.dba](https://avatars.discourse-cdn.com/v4/letter/r/e8c25b/32.png) [@rjwagner.dba](https://forum.ansible.com/u/rjwagner.dba)\
**Post date:** [December 5, 2018, 11:16pm UTC](https://forum.ansible.com/t/dig-lookup-multiple-hosts/29205/3 "2018-12-05T23:16:05Z")

</div>

Thanks Kai. That worked. I think I don’t quite understand lookup plugins (aside from with\_items). I’ll keep researching.

Rob
