0

我正在尝试使用Ansible模块(例如https://docs.ansible.com/ansible/latest/collections/community/general/one_image_info_module.html)管理在opennebula上运行的虚拟机

我在运行 macOS 10.15.6 和 python 3.8.5 的 Mac 上安装了 python 模块pyone ( http://docs.opennebula.io/5.12/integration/system_interfaces/python.html )

pip3 install pyone

pip3 list | grep pyone
pyone                 5.12.4

我的剧本:

---
- hosts: localhost

  tasks:
  - name: "test"
    community.general.one_image_info:
      api_url: https://one.mycompany.com:2633/RPC2
      api_username: myusername
      api_password: mypassword
    register: result

任务失败

fatal: [localhost]: FAILED! => {"changed": false, "msg": "This module requires pyone to work!"}

ansible localhost -m setup -a filter="ansible_python"告诉我 ansible 使用的是相同的 python 版本。

在一个普通的python脚本中,我可以毫无问题地导入pyone,现在我不知道在哪里调查..

我希望有人能指出我正确的方向!提前谢谢了

PS:输出ansible --version

ansible 2.10.1
  config file = /Users/fabian/projects/server-automation/ansible.cfg
  configured module search path = ['/Users/fabian/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.8/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.8.5 (default, Jul 21 2020, 10:48:26) [Clang 11.0.3 (clang-1103.0.32.62)]

Pyone 和我需要安装以使用其他 ansible 剧本的其他 python 模块位于:/usr/local/lib/python3.8/site-packages

4

2 回答 2

0

我同意它看起来确实使用了错误的 python 版本。您可以尝试将以下内容添加到您的剧本中吗?

  vars:
    ansible_python_interpreter: '/usr/bin/python3'
于 2020-10-02T13:08:44.690 回答
0

尝试 sudo pip3 安装。为我工作:

sudo pip3 install pyone

于 2020-12-14T12:07:04.383 回答