Help with with_items and vmware_guest

Hi,

I’m trying to do something that I thought would be very straghtfoward.
I’m deploying 3 vms (VMware) on a DHCP network - I then want to get the IP address of the VM and connect to it, just a simple ping.

`

  • name: Create stack
    hosts: localhost
    connection: local
    gather_facts: no
    tasks:
  • name: Create Master
    vmware_guest:
    hostname: “{{hostname}}”
    username: administrator@vsphere.local
    password: “{{password}}”
    validate_certs: False
    name: testansible2
    template: T-CentOS-7.5-Server-x64
    datacenter: US
    folder: /DC/vm/Deploy
    state: poweredon
    wait_for_ip_address: yes
    register: vm_master

- debug: var=vm_master

  • name: Add Master to inventory
    add_host:
    name: “{{ vm_master.instance.ipv4 }}”
    groups: master

  • name: Create Workers
    vmware_guest:
    hostname: “{{hostname}}”
    username: administrator@vsphere.local
    password: “{{password}}”
    validate_certs: False
    name: “{{item.vmname}}”
    template: T-CentOS-7.5-Server-x64
    datacenter: US
    folder: /DC/vm/Deploy
    state: poweredon
    wait_for_ip_address: yes
    with_items:

  • { vmname: “worker1”}

  • { vmname: “worker2”}
    register: vm_workers

- debug: var=vm_workers

  • name: Add Workers to inventory
    add_host:
    name: “{{ item.instance.ipv4 }}”
    groups: workers
    with_items: “{{ vm_workers.instances }}”

  • hosts: workers
    tasks:

  • name: Check connection
    ping:

`

The add master works - the add worker with_items loop doesn’t. I’ve tried vm_workers.instance / vm_workers.results but all result is sort of errror.

Any help much appreicated!