# Get basic vmware module working - vmware\_guest\_find

**URL:** <https://forum.ansible.com/t/get-basic-vmware-module-working-vmware-guest-find/27491>\
**Category:** Ansible Project\
**Tags:** vmware, rhel\
**Created:** [May 9, 2018, 2:52pm UTC](https://forum.ansible.com/t/get-basic-vmware-module-working-vmware-guest-find/27491 "2018-05-09T14:52:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Edward\_Ahern](https://avatars.discourse-cdn.com/v4/letter/e/3be4f8/32.png) [@Edward\_Ahern](https://forum.ansible.com/u/Edward_Ahern)\
**Post date:** [May 9, 2018, 2:52pm UTC](https://forum.ansible.com/t/get-basic-vmware-module-working-vmware-guest-find/27491/1 "2018-05-09T14:52:01Z")

</div>

Hi,

I’m having issues with getting basic VMware modules working. For example vmware\_guest\_find. I’m running the below from a RHEL 7 server.

Versions installed:

`  
pyvmomi 6.7.0  
ansible 2.5.2  
vSphere vCenter 6.0

`

playbook:

`

---

<div class="post-metadata">

**Author:** ![Nick\_Rogers](https://avatars.discourse-cdn.com/v4/letter/n/eb8c5e/32.png) [@Nick\_Rogers](https://forum.ansible.com/u/Nick_Rogers)\
**Post date:** [May 9, 2018, 6:54pm UTC](https://forum.ansible.com/t/get-basic-vmware-module-working-vmware-guest-find/27491/2 "2018-05-09T18:54:56Z")

</div>

It looks like your problem is using the “vm\_hostname” in the task.

In my experiments, I either use “{{ inventory\_hostname }}” for a per vm/host/target definition in the hosts group or a “with\_items” loop:

`

- name: Find Guest’s Folder using name  
vmware\_guest\_find:  
hostname: “{{ vmware\_esxi.hostname }}”  
validate\_certs: “{{ vmware\_esxi.validate\_certs }}”  
username: “{{ vmware\_esxi.username }}”  
password: “{{ vmware\_esxi.password }}”  
datacenter: “{{ vmware\_esxi.datacenter }}”  
name: “{{ item }}”  
delegate\_to: localhost  
tags: findvm  
with\_items:
- “{{ vm\_hostname }}”  
`

---

<div class="post-metadata">

**Author:** ![Edward\_Ahern](https://avatars.discourse-cdn.com/v4/letter/e/3be4f8/32.png) [@Edward\_Ahern](https://forum.ansible.com/u/Edward_Ahern)\
**Post date:** [May 10, 2018, 9:06am UTC](https://forum.ansible.com/t/get-basic-vmware-module-working-vmware-guest-find/27491/3 "2018-05-10T09:06:31Z")

</div>

Hi Nick,

Thanks for the response. I’m actually basing my tasks on your github repo you shared!  
So I’ve tried what you suggested but its not returning any data.

Updated task:

`

- name: Find Guest’s Folder using name  
vmware\_guest\_find:  
hostname: “{{ vmware\_esxi.hostname }}”  
validate\_certs: “{{ vmware\_esxi.validate\_certs }}”  
username: “{{ vmware\_esxi.username }}”  
password: “{{ vmware\_esxi.password }}”  
datacenter: “{{ vmware\_esxi.datacenter }}”  
name: “{{ item }}”  
delegate\_to: localhost  
tags: findvm  
with\_items:
- “{{ vm\_hostname }}”  
`

Playbook run:

`

# ansible-playbook -i hosts vmware-template.yml --tags findvm

PLAY [vms] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
TASK [vmware-template : Find Guest’s Folder using name] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [testvm01 → localhost]  
PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
testvm01 : ok=1 changed=0 unreachable=0 failed=0  
`

The VM is definitely in a folder.  
I can see the session opening in the VMware client so I’m assuming that its connecting and versions of the various software components are compatible.  
Must be missing something simple

Regards,

Ted

---

<div class="post-metadata">

**Author:** ![Nick\_Rogers](https://avatars.discourse-cdn.com/v4/letter/n/eb8c5e/32.png) [@Nick\_Rogers](https://forum.ansible.com/u/Nick_Rogers)\
**Post date:** [May 10, 2018, 4:50pm UTC](https://forum.ansible.com/t/get-basic-vmware-module-working-vmware-guest-find/27491/4 "2018-05-10T16:50:49Z")

</div>

The play is running properly, but I’m not sure what your intent is for the output. Try running it with -vvv, or if you register a variable like

`

- name: “Find Guest’s Folder using name”  
vmware\_guest\_find:  
hostname: “{{ vmware\_esxi.hostname }}”  
validate\_certs: “{{ vmware\_esxi.validate\_certs }}”  
username: “{{ vmware\_esxi.username }}”  
password: “{{ vmware\_esxi.password }}”  
datacenter: “{{ vmware\_esxi.datacenter }}”  
name: “{{ item }}”  
delegate\_to: localhost  
register: vm\_folder  
tags: findvm  
with\_items:

- “{{ vm\_hostname }}”

- name: debug vm\_folder  
debug:  
var: vm\_folder

`

You will then see what it’s doing and can move on from there.
