vmware_guest requires datacenter to display VM's facts

Hello All,

I’m using Ansible 2.3 RC2.

According to the sample comments in the code (https://github.com/ansible/ansible-modules-extras/blob/devel/cloud/vmware/vmware_guest.py), this is all I need to get a VM facts:

Gather facts only

  • name: gather the VM facts
    vmware_guest:
    validate_certs: False
    hostname: 192.168.1.209
    username: administrator@vsphere.local
    password: vmware
    name: testvm_2
    esxi_hostname: 192.168.1.117
    register: facts

But when I run my playbook:

  • name: Gather Facts about the VMs
    hosts: modify
    gather_facts: False
    connection: local
    vars_files:
  • group_vars/vault/lab_credentials.yml
    tasks:
  • name: gather the VM facts
    vmware_guest:
    validate_certs: False
    hostname: “{{ vcenter_hostname }}”
    username: “{{ vcenter_user }}”
    password: “{{ vcenter_passwd }}”
    name: “{{ guest_name }}”
    esxi_hostname: “{{ guest_esxhost }}”
    register: facts

It asks me for the datacenter name:

“No datacenter named ha-datacenter was found”

I give it the datacenter name in the playbook, but it complaints about datastore name not specified:

“Failed to find a matching datastore”

Following down down this path I realize that Ansible is trying to create a VM. Why? What am I missing? It is exactly the same code from the samples…

ansible-module-core and ansible-module-extras is merged in the Ansible code so they are not in use anymore.
Please use the official documentation instead.
https://docs.ansible.com/ansible/list_of_cloud_modules.html#vmware

It's a new module that handles facts in 2.3.

OK, now I’m using the vmware_guest_facts module, which seems to be the way to gather facts now. I’m using the exact same syntax as the example, still doesn’t work, Ansible asks me for the datacenter name, which is not included in the example:

https://docs.ansible.com/ansible/vmware_guest_facts_module.html#options
say datacenter is required, so probably error in the example.
So just add it and see if it works.

If I give it the datacenter, then it complaints about: “msg”: “Unable to gather facts for non-existing VM ansclient111”

However, if I try with vsphere_guest, it works:

This is the code for the vmware_guest_facts playbook that can’t find the VM:

I can confirm everything, I have exactly the same problem.

Hi guys

I still have this same issue even on a 2.6.3 version of Ansible and a 6.7 vSphere system
vsphere_guest works, vmware_guest_facts does not.
Any progress or hints from the group would be most welcome :0)
Thanks