Answered my own question:
- name: add the dhcp addresses to the inventory
add_host: name="{{ item.ansible_facts.hw_eth0.ipaddresses[0] }}"
groups=dhcp_ips
with_items:
- "{{ vm_facts.results }}"
On Thursday, June 16, 2016 at 10:54:28 PM UTC-7, Jeff Richards wrote:
>
> I'm trying to populate the in-memory inventory, for multiple VMs, using
> the output from vmware_guest_facts. So I have run vmware_guest_facts and
> registered the output into a var called vm_facts. I can see that the output
> contains facts for every VM, including the IP address, as expected.
>
> I then try to add the ip address for each VM into the inventory, as
> follows:
>
> - name: add the dhcp addresses to the inventory
> add_host: name="{{ hw_eth0.ipaddresses[0] }}" groups=dhcp_ips
> with_items:
> - "{{ vm_facts }}"
>
> But I only seem to be getting the IP address of the final VM in the
> inventory.
>
> Any help on how I should be doing this would be greatly appreciated.
>
> Jeff
>
--
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/2836c40d-8bff-4ccd-b4fd-4a866342c90d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.