Ansible + VMware Fusion

Consultar todas las MV de la librería de VMware Fusion.

ansible-playbook -i environments/vmfusion_inventory fusion_api.yml
vmfusion_inventory
[fusion_server]
macosserver	ansible_host=172.16.135.1	ansible_user=myuser
fusion_api.yml
---

- hosts: vmware_fusion
#  gather_facts: no

  tasks:
  - name: Check that you can connect (GET) to a page and it returns a status 200
    uri:
      url: https://172.16.135.1:8697/api/vms
      method: GET
      force_basic_auth: yes
      password: "ZmxlYWw6RmVyLm5hbmRvOTk="
      body_format: json
      return_content: yes
      validate_certs: false
      headers:
        Content-Type: "application/vnd.vmware.vmw.rest-v1+json"
        Authorization: "Basic ZmxlYWw6RmVyLm5hbmRvOTk="
        Accept: "application/vnd.vmware.vmw.rest-v1+json"
    register: vVMs

  - name: Debug
    debug:
      msg: "Mensaje Debug: {{ item.id }} {{ item.path }}"
    with_items: "{{ vVMs.json  }}"

[root@ansible]# ansible-playbook -i environments/vmfusion_inventory fusion_api.yml 

PLAY [macosserver]  *************************************************************************************************

TASK [Gathering Facts] **********************************************************************************************
ok: [macosserver]

TASK [Check that you can connect (GET) to a page and it returns a status 200] ***************************************
ok: [macosserver]

TASK [Debug] PLAY RECAP *********************************************************************************************
ok: [macosserver] => (item={u'path': u'/Virtual Machines/DUMMY.vmwarevm/DUMMY.vmx', u'id': u'H0EGD24AAR2GDO7LGMQ1VREQI18D5PND'}) => {
    "msg": "Mensaje Debug: H0EGD24AAR2GDO7LGMQ1VREQI18D5PND /Virtual Machines/DUMMY.vmwarevm/DUMMY.vmx"
}
ok: [macosserver] => (item={u'path': u'/Virtual Machines/RHEL7.vmwarevm/RHEL7.vmx', u'id': u'IE9OGI48API926RS4B81VTAJRTO3C6TQ'}) => {
    "msg": "Mensaje Debug: IE9OGI48API926RS4B81VTAJRTO3C6TQ /Virtual Machines/RHEL7.vmwarevm/RHEL7.vmx"
}

PLAY RECAP **********************************************************************************************************
macosserver                 : ok=3    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0