Thanks Kai. That worked. I think I don’t quite understand lookup plugins (aside from with_items). I’ll keep researching.
Rob > On Dec 5, 2018, at 3:08 PM, Kai Stian Olstad > <[email protected]> wrote: > >> 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 a topic in the Google > Groups "Ansible Project" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/ansible-project/4EeglD0c4yg/unsubscribe. > To unsubscribe from this group and all its topics, 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. -- 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/53406941-C114-46B7-B7F2-34662BEB110A%40gmail.com. For more options, visit https://groups.google.com/d/optout.
