# vmware\_guest requires datacenter to display VM's facts

**URL:** <https://forum.ansible.com/t/vmware-guest-requires-datacenter-to-display-vms-facts/24145>\
**Category:** Ansible Project\
**Tags:** vmware\
**Created:** [April 4, 2017, 9:01pm UTC](https://forum.ansible.com/t/vmware-guest-requires-datacenter-to-display-vms-facts/24145 "2017-04-04T21:01:11Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Diego\_Puertas](https://avatars.discourse-cdn.com/v4/letter/d/e480ec/32.png) [@Diego\_Puertas](https://forum.ansible.com/u/Diego_Puertas)\
**Post date:** [April 4, 2017, 9:01pm UTC](https://forum.ansible.com/t/vmware-guest-requires-datacenter-to-display-vms-facts/24145/1 "2017-04-04T21:01:11Z")

</div>

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](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…

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [April 5, 2017, 10:28am UTC](https://forum.ansible.com/t/vmware-guest-requires-datacenter-to-display-vms-facts/24145/2 "2017-04-05T10:28:39Z")

</div>

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](https://docs.ansible.com/ansible/list_of_cloud_modules.html#vmware)

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

---

<div class="post-metadata">

**Author:** ![Diego\_Puertas](https://avatars.discourse-cdn.com/v4/letter/d/e480ec/32.png) [@Diego\_Puertas](https://forum.ansible.com/u/Diego_Puertas)\
**Post date:** [April 5, 2017, 3:12pm UTC](https://forum.ansible.com/t/vmware-guest-requires-datacenter-to-display-vms-facts/24145/3 "2017-04-05T15:12:31Z")

</div>

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:

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [April 5, 2017, 3:21pm UTC](https://forum.ansible.com/t/vmware-guest-requires-datacenter-to-display-vms-facts/24145/4 "2017-04-05T15:21:20Z")

</div>

[https://docs.ansible.com/ansible/vmware\_guest\_facts\_module.html#options](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.

---

<div class="post-metadata">

**Author:** ![Diego\_Puertas](https://avatars.discourse-cdn.com/v4/letter/d/e480ec/32.png) [@Diego\_Puertas](https://forum.ansible.com/u/Diego_Puertas)\
**Post date:** [April 5, 2017, 3:26pm UTC](https://forum.ansible.com/t/vmware-guest-requires-datacenter-to-display-vms-facts/24145/5 "2017-04-05T15:26:20Z")

</div>

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:

---

<div class="post-metadata">

**Author:** ![Diego\_Puertas](https://avatars.discourse-cdn.com/v4/letter/d/e480ec/32.png) [@Diego\_Puertas](https://forum.ansible.com/u/Diego_Puertas)\
**Post date:** [April 5, 2017, 3:29pm UTC](https://forum.ansible.com/t/vmware-guest-requires-datacenter-to-display-vms-facts/24145/6 "2017-04-05T15:29:43Z")

</div>

This is the code for the vmware\_guest\_facts playbook that can’t find the VM:

---

<div class="post-metadata">

**Author:** ![thirsch.epages](https://avatars.discourse-cdn.com/v4/letter/t/43a26b/32.png) [@thirsch.epages](https://forum.ansible.com/u/thirsch.epages)\
**Post date:** [October 4, 2017, 3:13pm UTC](https://forum.ansible.com/t/vmware-guest-requires-datacenter-to-display-vms-facts/24145/7 "2017-10-04T15:13:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Michael\_Gimm](https://avatars.discourse-cdn.com/v4/letter/m/eb9ed0/32.png) [@Michael\_Gimm](https://forum.ansible.com/u/Michael_Gimm)\
**Post date:** [September 6, 2018, 7:57pm UTC](https://forum.ansible.com/t/vmware-guest-requires-datacenter-to-display-vms-facts/24145/8 "2018-09-06T19:57:26Z")

</div>

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
