0

I am trying to manage my VMs running on opennebula using the Ansible modules (e.g. https://docs.ansible.com/ansible/latest/collections/community/general/one_image_info_module.html )

I installed the python module pyone on my mac running macOS 10.15.6 with python 3.8.5 ( http://docs.opennebula.io/5.12/integration/system_interfaces/python.html )

pip3 install pyone

pip3 list | grep pyone
pyone                 5.12.4

My playbook:

---
- 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

The task fails with

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

ansible localhost -m setup -a filter="ansible_python" tells me that ansible is using the same python version.

In a normal python script I can import pyone without problems and now I am clueless where to investigate..

I hope someone can point me in the right direction! Many thanks in advance

P.S.: Output of 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 and other python modules I needed to installed to use other ansible playbooks are located here: /usr/local/lib/python3.8/site-packages

fabian
  • 13
  • 3
  • 1
    Check the output of `ansible localhost -m setup -a filter="ansible_python"` and compare with the version of python you installed the module in. Chances are you installed in one version and ansible is "remotely" (although it is localhost....) using an other discovered version. If this is the case, either install the lib in the other version as well or tune the [python interpreter discovery](https://docs.ansible.com/ansible/latest/reference_appendices/interpreter_discovery.html) so that is uses the correct one. – Zeitounator Oct 01 '20 at 10:46
  • thanks. Sadly it is also using python 3.8.5 – fabian Oct 01 '20 at 11:24
  • You can help this problem, as well as your future colleagues who wish to run this playbook, by adding a task right before that one to explicitly install pyone: `- ansible.builtin.pip: name=pyone state=present`; if you already have it installed as you claim, nothing will change, but if you are using the wrong python (as we strongly suspect), or move to a new machine, then that task will ensure the dependency is intact before attempting to use the `one_image_info` right below it – mdaniel Oct 01 '20 at 14:11
  • Thank you. This is helpful, but in this case it still doesn't work. The task finishes with status ok. I uninstalled pyone and ran the playbook again. It installed pyone but the next task still failes with the same error. – fabian Oct 02 '20 at 06:39

2 Answers2

0

I agree that it really looks like a wrong python version is used. Could you try to add the following to your playbook?

  vars:
    ansible_python_interpreter: '/usr/bin/python3'
jorel
  • 63
  • 5
0

try sudo pip3 install. worked for me:

sudo pip3 install pyone

spl5
  • 1