user3796292 user3796292 - 3 months ago 478
YAML Question

Pysphere error when running playbook

---
- 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.

Answer

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.

Comments