0
votes
---
- hosts: my-host
  tasks:
    - vsphere_guest:
        vcenter_hostname: vcenter.mydomain.local
        username: myuser
        password: mypass
        guest: newvm001
        vmware_guest_facts: yes

When I run this playbook, I get this error

PLAY [my-host]


TASK [setup] ******************************************************************* ok: [19.3.112.97 ]

TASK [vsphere_guest] *********************************************************** fatal: [19.3.112.97 ]: FAILED! => {"changed": false, "failed": true, "msg": "pysphere module required"}

NO MORE HOSTS LEFT ************************************************************* [WARNING]: Could not create retry file 'createvms.retry'.
[Errno 2] No such file or directory: ''

PLAY RECAP


19.3.112.97 : ok=1 changed=0 unreachable=0 failed=1

Why do I get this error? I have uninstalled and installed pysphere. I have used previous and current versions of it but I still get this error.

1
You installed psyphere on the control host? How? - mwp
I used pip install. 'sudo pip install pysphere' - user3796292
My initial thought is that you have more than one python installed on your system and Ansible is using the "wrong" one. - mwp
That makes sense. Let me look further into it and see if that is the case. Thanks - user3796292
@mwp What is a datacenter again? And how do I get the correct datacenter to use? Thanks - user3796292

1 Answers

1
votes

You usually want to run cloud/VM management modules from your control machine (localhost). This would look like this:

---
- hosts: localhost
  connection: local
  tasks:
    - vsphere_guest:
        vcenter_hostname: vcenter.mydomain.local
        username: myuser
        password: mypass
        guest: newvm001
        vmware_guest_facts: yes

In this case ansible use PySphere installed on your control host to connect to vcenter.mydomain.local and provision VMs.

In your example PySphere should be installed on 19.3.112.97 and vcenter.mydomain.local should be accessible from that host.