On Wednesday, 5 December 2018 19:55:46 CET [email protected] wrote:
> 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). 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:
> ---
> - hosts: all
> vars:
> db_hosts=['host1.example.com', 'host2.example.com']
> tasks:
> - debug: msg='IP is {{ item }}'
> with_items: "{{ lookup('dig', 'BLAH', wantlist=False) }}"
>
> but what to put in for BLAH if I want to get the IPs for the list given by
> db_hosts?
I'm might misunderstand you question, but if you turn it around I think get
your answer
- debug: msg='IP for {{ item }} is {{ lookup('dig', item) }}'
with_items: "{{ db_hosts }}"
--
Kai Stian Olstad
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/1897030.6mZVLSW9GO%40x1.
For more options, visit https://groups.google.com/d/optout.