3

I am running my playbook with the following command:

ansible-playbook kubernetes_cluster.yml -b --ask-pass -vvv

My error message is:

    Traceback (most recent call last):
  File "/tmp/ansible_k8s_payload_2BRCdT/ansible_k8s_payload.zip/ansible/module_utils/k8s/common.py", line 33, in <module>
    import kubernetes
ImportError: No module named kubernetes
fatal: [kube1.idm.nac-issa.org]: FAILED! => {
    "changed": false,
    "error": "No module named kubernetes",
    "invocation": {
        "module_args": {
            "api_key": null,
            "api_version": "v1",
            "append_hash": false,
            "apply": false,
            "ca_cert": null,
            "client_cert": null,
            "client_key": null,
            "context": null,
            "force": false,
            "host": null,
            "kind": "Namespace",
            "kubeconfig": "/root/.kube/config",
            "merge_type": null,
            "name": "",
            "namespace": null,
            "password": null,
            "proxy": null,
            "resource_definition": null,
            "src": null,
            "state": "present",
            "username": null,
            "validate": null,
            "validate_certs": null,
            "wait": false,
            "wait_condition": null,
            "wait_sleep": 5,
            "wait_timeout": 120
        }
    },
    "msg": "Failed to import the required Python library (openshift) on kube1.idm.nac-issa.org's Python /usr/bin/python. Please read module documentation and install in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter"

My environment:

ansible 2.9.16
  config file = /home/ansuser/ansible/ansible.cfg
  configured module search path = ['/home/ansuser/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.6/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.6.8 (default, Apr 16 2020, 01:36:27) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]

I followed the directions from a similar question and performed the pip installs on the target host (not the management host)- Ansible K8s module: Failed to import the required Python library (openshift) on Python /usr/bin/python3 and Cannot execute k8s module but that hasn't made any difference

pip3 install openshift pyyaml kubernetes and also `sudo pip3 install --upgrade --user openshift`

I'm stuck figuring out what to try next. Any ideas are appreciated!

  • did you install it on the Ansible node only? You should also install Python packages on the target nodes. – Vasili Angapov Jan 24 '21 at 13:15
  • @mdaniel, thanks for the comment when you say which python it used I think you mean /usr/bin/python, correct? Are you suggesting to use the -e option with my ansible command to control which python version is being used? So, if I understand correctly, I need to be sure the kubernetes module is installed in the ansible python module location but the playbook is using /usr/bin/python. The location mismatch is causing issues? – Jeremy Tourville Jan 24 '21 at 13:44

0 Answers0