我有一本剧本,可以在vmware环境中创建一个vm,但是它总是弹出并显示错误**需要PyVmomi Python模块。使用\“ pip install PyVmomi **安装,即使我已经安装了它。 有人可以帮我解决这个问题
[环境]
[root@ansible]# ansible --version
ansible 2.7.0
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.5 (default, Apr 11 2018, 07:36:10) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]
[root@ansible]# pip show pyvmomi
Name: pyvmomi
Version: 6.7.0.2018.9
Summary: VMware vSphere Python SDK
Home-page: https://github.com/vmware/pyvmomi
Author: VMware, Inc.
Author-email: jhu@vmware.com
License: License :: OSI Approved :: Apache Software License
Location: /usr/lib/python2.7/site-packages
Requires: requests, six
Required-by:
[PlayBook]
[root@ansible]# cat vmware.yml
---
- hosts: localhost
connection: local
gather_facts: no
tasks:
- name: Clone the template
vmware_guest:
hostname: **.**.**.**
username: root
password: *****
validate_certs: False
name: ansible-vm
template: template-gold
datacenter: DC1
folder: /DC1/vm
state: poweredon
wait_for_ip_address: yes
我正在编辑我的问题并发布询问的结果。 带有以下详细信息的已编辑主机文件
[my_ws] 本地主机ansible_python_interpreter = {{ansible_playbook_python}}
错误.. [root @ ansible]#ansible-playbook test1.yml
PLAY [本地主机] *********************************************** **************************************
任务[聚会事实] ********************************************** **************************** 好的:[localhost]
任务[命令] *********************************************** *************************************** 致命的:[本地主机]:失败! => {“ changed”:true,“ cmd”:[“ / usr / bin / python2”,“ -c”,“导入pyvmomi; print(pyvmomi。版本)”]],“ delta “:” 0:00:00.090749“,”结束“:” 2018-10-10 11:12:22.345576“,” msg“:”非零返回码“,” rc“:1,”开始“:” 2018-10-10 11:12:22.254827“,” stderr“:”追踪(最近一次通话最近):\ n File \“ \”,\ n行1,\ nImportError:没有名为pyvmomi的模块“,” stderr_lines“: [“追踪(最近一次通话):”,“文件\” \“,行1,在”,“ ImportError:没有名为pyvmomi的模块”],“ stdout”:“”,“ stdout_lines”:[]} 要重试,请使用:--limit @ / etc / ansible / test1.retry
PLAY RECAP ********************************************* ****************************************** 本地主机:ok = 1更改= 0 =无法访问= 0失败= 1