Ansible + vpshere_guest

829 views
Skip to first unread message

fmor...@gmail.com

unread,
Dec 14, 2014, 1:56:31 PM12/14/14
to ansible...@googlegroups.com
Hello all,

I'm starting with Ansible, and I would like to provsion a VMWare Cluster with it.
To do that, I use the vsphere-guest module. However, I try to use it!

So I create a role /etc/ansible/role/esx/task/main.yml and try to set up a VM.
I follow the the official documentetion: http://docs.ansible.com/vsphere_guest_module.html

But when I try to run my playbook, it doesn't work.
I've this error:

shell> ansible-playbook -i /etc/ansible/hosts /etc/ansible/base.yml -C
GATHERING FACTS ***************************************************************
failed: [ip_of_esx] => {"failed": true, "parsed": false}
Traceback (most recent call last):
  File "//.ansible/tmp/ansible-tmp-1418582864.23-99769666634275/setup", line 204, in <module>
    import grp
ImportError: No module named grp

And I don't find anything about this error, and I don't know how to solve it...

pysphere in lastest version is install (easy_install -U pysphere)
I try this command: ansible esx -m raw -a "date"
It works fine.

Somebody already try this module? Maybe I don't use it well...

Thanks a lot.

Chris Church

unread,
Dec 14, 2014, 11:31:51 PM12/14/14
to ansible...@googlegroups.com
The Python version installed on ESX doesn't include all the "standard" library code needed to run Ansible modules.  You're pretty much limited to using raw and script to do anything over SSH.

You may want to set gather_facts: false in your play to prevent trying to run the setup module.

The vsphere_guest module is meant to be run on the control machine, using local_action or delegate_to.  The following play shows an example of connecting to an ESXi server using both SSH and PySphere:


- hosts: vmware
  gather_facts: false
  tasks:
    - raw: uname -a
    - vsphere_guest:
        vcenter_hostname: "{{ ansible_ssh_host|default(inventory_hostname) }}"
        username: "{{ hostvars[inventory_hostname].ansible_ssh_user|quote }}"
        password: "{{ hostvars[inventory_hostname].ansible_ssh_pass|quote }}"
        guest: "My Guest"
        vmware_guest_facts: yes
      delegate_to: localhost



--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/6dcb33d0-653d-4613-a990-bfb6ea936f3b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages