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:
---
- hosts: vms

  roles:
     - vmware-template

Role task:
---
# tasks file for vmware-template

- 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: "{{ vm_hostname }}"
  delegate_to: localhost
  tags: findvm

Role vars:(sensitive info hashed out)

---
# vars file for vmware-template
vmware_esxi:
  hostname: #######
  validate_certs: no
  username: #######
  password: ########
  datacenter: #######
 
vm_hostname:
   - testvm01

Hosts file:
[local]
localhost

[vms]
testvm01



Playbook run: (sensitive info hashed out)

# ansible-playbook -i hosts vmware-template.yml --tags findvm -vvvv
ansible-playbook 2.5.2
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u
'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /bin/ansible-playbook
  python version = 2.7.5 (default, May  3 2017, 07:55:04) [GCC 4.8.5 
20150623 (Red Hat 4.8.5-14)]
Using /etc/ansible/ansible.cfg as config file
setting up inventory plugins
Set default localhost to localhost
Parsed /etc/ansible/plays/hosts inventory source with ini plugin
Trying secret FileVaultSecret(filename='########') for vault_id=default
Loading callback plugin default of type stdout, v2.0 from /usr/lib/python2.7
/site-packages/ansible/plugins/callback/default.pyc
PLAYBOOK: vmware-template.yml 
**************************************************************************************************************************************************************
1 plays in vmware-template.yml
PLAY [vms] 
*********************************************************************************************************************************************************************************
META: ran handlers
TASK [vmware-template : Find Guest's Folder using name] 
************************************************************************************************************************************
task path: /etc/ansible/roles/vmware-template/tasks/main.yml:52
Using module file 
/usr/lib/python2.7/site-packages/ansible/modules/cloud/vmware/vmware_guest_find.py
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<localhost> EXEC /bin/sh -c 'echo ~ && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo 
/root/.ansible/tmp/ansible-tmp-1525877042.27-257095638403837 `" && echo 
ansible-tmp-1525877042.27-257095638403837="` echo 
/root/.ansible/tmp/ansible-tmp-1525877042.27-257095638403837 `" ) && sleep 0
'
<localhost> PUT /root/.ansible/tmp/ansible-local-24670bWH_Sz/tmptyQ4GF TO 
/root/.ansible/tmp/ansible-tmp-1525877042.27-257095638403837/vmware_guest_find.py
<localhost> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-
1525877042.27-257095638403837/ /root/.ansible/tmp/ansible-tmp-1525877042.27-
257095638403837/vmware_guest_find.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python /root/.ansible/tmp/ansible-tmp-
1525877042.27-257095638403837/vmware_guest_find.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-
1525877042.27-257095638403837/ > /dev/null 2>&1 && sleep 0'
fatal: [testvm01 -> localhost]: FAILED! => {
    "changed": false, 
    "invocation": {
        "module_args": {
            "datacenter": "#######", 
            "hostname": "###########", 
            "name": "['##########']", 
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
            "port": ###, 
            "username": "#####", 
            "uuid": null, 
            "validate_certs": false
        }
    }, 
    "msg": "Unable to find folders for virtual machine ['testvm01']"
}
        to retry, use: --limit @/etc/ansible/plays/vmware-template.retry
PLAY RECAP 
*********************************************************************************************************************************************************************************
testvm01         : ok=0    changed=0    unreachable=0    failed=1   



This is a pretty straight forward task but I don't understand why its 
failing. The vm exists, its powered on, VMware tools is running. I can see 
a new connection opening under the sessions tab in the vSphere client. I 
can query the VM from powercli.........

Does pyvmomi have to be installed on the vCenter host?

Any suggestions / comments are most welcome!

Thanks,

Ted



-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/d6aaa727-8894-44f4-8254-2fea955fe5e9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to