Module pysphere-ansible的麻烦

Module pysphere-ansible的麻烦,module,automation,ansible,vmware,Module,Automation,Ansible,Vmware,我正在尝试通过Ansible在我的ESXi主机上部署VM。 我正在为此使用以下角色: - vsphere_guest: vcenter_hostname: emea-esx-s18t.****.net username: **** password: **** guest: newvm001 state: powered_off vm_extra_config: vcpu.hotadd: yes mem.hotadd: y

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

- 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
当我现在通过剧本执行此角色时,我得到以下消息:

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”模块不见了。我已经用命令检查过了:

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
然后我进行了“升级”,并收到以下消息:

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让我发疯了

我希望你们能帮助我,提前谢谢

亲切问候,, 克格曼

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

因此,当我执行此剧本时,我得到以下错误:

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

斗争是真实的-。-

您通常应该在本地ansible机器上执行调配模块,如
vsphere\u guest

我怀疑
172.20.22.5
实际上是您的ESX主机,ansible尝试从那里执行模块,而pysphere肯定不在那里。
使用:


您通常应该在本地ansible计算机上执行设置模块,如
vsphere\u guest

我怀疑
172.20.22.5
实际上是您的ESX主机,ansible尝试从那里执行模块,而pysphere肯定不在那里。
使用:


在macOS/OSX上再次遇到此问题。。。 它似乎与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的特定版本
无论如何,这似乎解决了问题


来源:

在macOS/OSX上再次遇到这个问题。。。 它似乎与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的特定版本
无论如何,这似乎解决了问题


来源:

ypu是的,172.20.22.5是ESXi主机,但是如果我想在那里部署VM(因为那里有VCenter&stuff)——但是ESXi上的操作系统是Ubuntu以外的东西,那么,我如何仍然可以通过VSphere上的Ansible创建VM呢?您将其指定为
vcenter\u主机名
param–Ansible模块将从本地主机连接到它并创建请求的VM。抱歉,我不明白您的意思:/“您将其指定为vcenter\u主机名参数”,您能给我举个例子吗?在您的示例playbook中,ansible将使用用户
**
和密码
**
连接到
emea-esx-s18t.***.net
,并创建VM
newvm001
。你只需要在本地主机上调用这个任务,而不是在ESX主机上调用。所以你的意思是我需要这样做:是的,ypu是对的,172.20.22.5是ESXi主机,但是如果我想在那里部署一个VM(因为有VCenter&stuff)——但是ESXi上的操作系统是其他的,而不是Ubuntu,那么,我如何仍然可以通过VSphere上的Ansible创建VM呢?您将其指定为
vcenter\u主机名
param–Ansible模块将从本地主机连接到它并创建请求的VM。抱歉,我不明白您的意思:/“您将其指定为vcenter\u主机名参数”,您能给我举个例子吗?在您的示例playbook中,ansible将使用用户
**
和密码
**
连接到
emea-esx-s18t.***.net
,并创建VM
newvm001
。您只需要在localhost上调用此任务,而不是在ESX主机上调用。您的意思是我需要这样调用它:
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"