pysphere 的问题 - ansible [英] trouble with pysphere - ansible

查看:15
本文介绍了pysphere 的问题 - ansible的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过 Ansible 在我的 ESXi 主机上部署虚拟机.我为此使用以下角色:

i am trying to deploy a VM via Ansible on my ESXi host. I am using the following role for this:

- vsphere_guest:
    vcenter_hostname: emea-esx-s18t.****.net
    username: ****
    password: ****
    guest: newvm001
    state: powered_off
    vm_extra_config:
      vcpu.hotadd: yes
      mem.hotadd:  yes
      notes: This is a test VM
    vm_disk:
      disk1:
        size_gb: 10
        type: thin
        datastore: ****
    vm_nic:
      nic1:
        type: vmxnet3
        network: VM Network
        network_type: standard
    vm_hardware:
      memory_mb: 4096
      num_cpus: 4
      osid: windows7Server64Guest
      scsi: paravirtual
    esxi:
      datacenter: MyDatacenter
      hostname: esx-s18t.****.net

当我现在通过剧本执行此角色时,我收到以下消息:

when i execute this role now via a playbook i get the following message:

root@ansible1:~/ansible# ansible-playbook -i Inventory vmware_deploy.yml

PLAY ***************************************************************************

TASK [setup] *******************************************************************
ok: [172.20.22.5]

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

PLAY RECAP *********************************************************************
172.20.22.5                : ok=1    changed=0    unreachable=0    failed=1

所以似乎缺少pysphere"模块.我已经用命令检查过了:

So it seems to be "pysphere" module is missing. i've already checked that with the command:

root@ansible1:~/ansible# pip install pysphere
Requirement already satisfied (use --upgrade to upgrade): pysphere in /usr/local/lib/python2.7/dist-packages/pysphere-0                          .1.7-py2.7.egg

然后我进行了升级"并得到以下消息:

Then i did the "upgrade" and get the following message back:

root@ansible1:~/ansible# pip install pysphere --upgrade
Requirement already up-to-date: pysphere in /usr/local/lib/python2.7/dist-packages/pysphere-0.1.7-py2.7.egg

所以它似乎已经安装并且是最新的,为什么我会收到此错误消息?我该如何解决我该死的角色现在可以正常工作的问题?天啊,Ansible 让我发疯..

So it seems to be it is already installed and its up-to-date , why do i get this error message then? How can i fix it that my god damn role works fine now? Jesus, Ansible makes me crazy ..

我希望你们能帮助我,在此先感谢!

I hope you guys can help me, thanks in advance!

亲切的问候,吉尔曼

所以我用旧的东西写了一个新的剧本,新的剧本看起来像这样(我已经添加了你的本地主机和连接本地的东西):

so i've writen a new playbook with the old stuff, the new playbool lookes like this(i've added your localhost and connection local stuff):

---
- hosts: localhost
  connection: local
  tasks:
    vsphere_guest:
        vcenter_hostname: emea-esx-s18t.****.net
            username: ****
            password: ****
            guest: newvm001
            state: powered_off
        vm_extra_config:
            vcpu.hotadd: yes
            mem.hotadd:  yes
            notes: This is a test VM
        vm_disk:
            disk1:
            size_gb: 10
            type: thin
            datastore: ****
        vm_nic:
            nic1:
            type: vmxnet3
            network: VM Network
            network_type: standard
        vm_hardware:
            memory_mb: 4096
            num_cpus: 4
            osid: windows7Server64Guest
            scsi: paravirtual
        esxi:
            datacenter: MyDatacenter
            hostname: esx-s18t.****.net

所以当我执行这个剧本时,我收到以下错误:

so when i execute this playbook i get the following error:

root@ansible1:~/ansible# ansible-playbook vmware2.yml
ERROR! Syntax Error while loading YAML.


The error appears to have been in '/root/ansible/vmware2.yml': line 7, column 19, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

        vcenter_hostname: emea-esx-s18t.sddc-hwl-family.net
          username: root
                  ^ here

斗争是真实的-.-

推荐答案

在 macOS/OSX 上再次遇到这个问题...它似乎与PYTHONPATH有关.

Ran into this issue once again on macOS / OSX... It seems to be related to PYTHONPATH.

我的 .profile 中有这个:

export PYTHONPATH="/usr/local/lib/python2.7/site-packages"

[ ... further down ... ]

export PYTHONPATH="/usr/local/Cellar/ansible/2.1.2.0/libexec/lib/python2.7/site-packages:/usr/local/Cellar/ansible/2.2.1.0/libexec/vendor/lib/python2.7/site-packages:$PYTHONPATH"

带有 PYTHONPATH 的第一行是 pysphere 和其他系统模块所在的位置.
还要注意 Ansible 的特定版本
无论如何,这似乎解决了问题.

The first line with PYTHONPATH is where pysphere and other system modules reside.
Also take note of the specific version of Ansible!
Anyway, this seems to resolve the issue.

来源:https://github.com/debops/debops-工具/问题/159#issuecomment-236536195

这篇关于pysphere 的问题 - ansible的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆