Skip to content Skip to sidebar Skip to footer

Ansible K8s Module: Failed To Import The Required Python Library (openshift) On Python /usr/bin/python3

The env Ansible 2.9.6 (python3) Tried to run a simple playbook - hosts: master gather_facts: no become: yes tasks: - name: create name space k8s: name: te

Solution 1:

Taking a look at the documentation here: https://docs.ansible.com/ansible/latest/modules/k8s_module.html

Seems like you need to have:

  • python >= 2.7
  • openshift >= 0.6
  • PyYAML >= 3.11

One way to do this is:

pip install openshift pyyaml kubernetes 

Side note, I've added kubernetes here but I believe it's a dependency of openshift.

Also we can do like this as well:

pip3 install openshift pyyaml kubernetes --user

Solution 2:

Define this variable in inventory - ansible_python_interpreter: /usr/local/bin/python3, it must help ansible to choose right interpreter during local connection.


Solution 3:

You're running the playbook with become: yes so the extension needs to be installed for the root user as well. Just had the same problem but sudo pip install openshift pyyaml fixed it for me.


Post a Comment for "Ansible K8s Module: Failed To Import The Required Python Library (openshift) On Python /usr/bin/python3"