简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM