Hi,
I’m trying to use ansible to interact with OKD (OpenShift upstream project) cluster. I have ansible installed within a virtual environment (python 3.8.10). Ansible version is:
ansible --version
ansible [core 2.13.10]
Listing collections with ansible-galaxy collection list
, I see the following versions for community.okd.k8s and kubernetes.core.k8s:
~/.ansible/collections/ansible_collections
Collection Version
community.okd 3.0.1
kubernetes.core 3.0.1
~/.venv/lib/python3.8/site-packages/ansible_collections
Collection Version
community.okd 2.2.0
kubernetes.core 2.3.2
I can use community.okd.openshift_auth to login but when it comes to using community.okd.k8s, the playbook gets stuck indefinitely.
Using community.okd.k8s
Example playbook that I’m trying to run:
- name: Setting up OKD
become: true
become_user: root
hosts: localhost
tasks:
- name: Login to OKD # not using this as it requires setting either the "environment" or "api_key" for each OKD tasks after login
community.okd.k8s_auth:
host: https://api.aspmokd01.all.space:6443
password: "{{ okd_admin_password }}"
username: "{{ okd_admin_user }}"
validate_certs: false
register: okd_auth
environment:
K8S_AUTH_API_KEY: okd_auth.openshift_auth
- name: Create a k8s namespace
community.okd.k8s:
api_key: okd_auth.openshift_auth
name: testing
api_version: v1
kind: Namespace
state: present
Below is how I’m trying to run it and the output for the community.okd.k8s
task.
ansible-playbook --ask-vault-pass -i ansible/inventory.yml ansible/playbooks/okd_deploy.yml -vvvvv
Output (full output is lengthy so only showing select bits and full output for the community.okd.k8s
task:
[WARNING]: Collection community.okd does not support Ansible version 2.13.10
[WARNING]: Collection kubernetes.core does not support Ansible version 2.13.10
TASK [Create a k8s namespace] **************************************************************************************************************************************************************************************************
task path: /home/user1/ansible_project/ansible/playbooks/okd_deploy.yml:16
redirecting (type: action) community.okd.k8s to kubernetes.core.k8s_info
redirecting (type: action) community.okd.k8s to kubernetes.core.k8s_info
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: user1
<localhost> EXEC /bin/sh -c 'echo ~user1 && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/user1/.ansible/tmp `"&& mkdir "` echo /home/user1/.ansible/tmp/ansible-tmp-1712586762.9948385-29764-140730930417156 `" && echo ansible-tmp-1712586762.9948385-29764-140730930417156="` echo /home/user1/.ansible/tmp/ansible-tmp-1712586762.9948385-29764-140730930417156 `" ) && sleep 0'
Including module_utils file ansible/__init__.py
Including module_utils file ansible/module_utils/__init__.py
Including module_utils file ansible/module_utils/basic.py
Including module_utils file ansible/module_utils/_text.py
Including module_utils file ansible/module_utils/common/_collections_compat.py
Including module_utils file ansible/module_utils/common/__init__.py
Including module_utils file ansible/module_utils/common/_json_compat.py
Including module_utils file ansible/module_utils/common/_utils.py
Including module_utils file ansible/module_utils/common/arg_spec.py
Including module_utils file ansible/module_utils/common/file.py
Including module_utils file ansible/module_utils/common/locale.py
Including module_utils file ansible/module_utils/common/parameters.py
Including module_utils file ansible/module_utils/common/collections.py
Including module_utils file ansible/module_utils/common/process.py
Including module_utils file ansible/module_utils/common/sys_info.py
Including module_utils file ansible/module_utils/common/text/converters.py
Including module_utils file ansible/module_utils/common/text/__init__.py
Including module_utils file ansible/module_utils/common/text/formatters.py
Including module_utils file ansible/module_utils/common/validation.py
Including module_utils file ansible/module_utils/common/warnings.py
Including module_utils file ansible/module_utils/compat/selectors.py
Including module_utils file ansible/module_utils/compat/__init__.py
Including module_utils file ansible/module_utils/compat/_selectors2.py
Including module_utils file ansible/module_utils/compat/selinux.py
Including module_utils file ansible/module_utils/distro/__init__.py
Including module_utils file ansible/module_utils/distro/_distro.py
Including module_utils file ansible/module_utils/errors.py
Including module_utils file ansible/module_utils/parsing/convert_bool.py
Including module_utils file ansible/module_utils/parsing/__init__.py
Including module_utils file ansible/module_utils/pycompat24.py
Including module_utils file ansible/module_utils/six/__init__.py
Including module_utils file ansible_collections/community/okd/plugins/module_utils/k8s.py
Including module_utils file ansible_collections/__init__.py
Including module_utils file ansible_collections/community/__init__.py
Including module_utils file ansible_collections/community/okd/__init__.py
Including module_utils file ansible_collections/community/okd/plugins/__init__.py
Including module_utils file ansible_collections/community/okd/plugins/module_utils/__init__.py
Including module_utils file ansible_collections/community/okd/plugins/module_utils/openshift_common.py
Including module_utils file ansible_collections/kubernetes/core/plugins/module_utils/args_common.py
Including module_utils file ansible_collections/kubernetes/__init__.py
Including module_utils file ansible_collections/kubernetes/core/__init__.py
Including module_utils file ansible_collections/kubernetes/core/plugins/__init__.py
Including module_utils file ansible_collections/kubernetes/core/plugins/module_utils/__init__.py
Including module_utils file ansible_collections/kubernetes/core/plugins/module_utils/k8s/client.py
Including module_utils file ansible_collections/kubernetes/core/plugins/module_utils/client/discovery.py
Including module_utils file ansible_collections/kubernetes/core/plugins/module_utils/client/__init__.py
Including module_utils file ansible_collections/kubernetes/core/plugins/module_utils/client/resource.py
Including module_utils file ansible_collections/kubernetes/core/plugins/module_utils/k8s/__init__.py
Including module_utils file ansible_collections/kubernetes/core/plugins/module_utils/k8s/core.py
Including module_utils file ansible_collections/kubernetes/core/plugins/module_utils/k8s/exceptions.py
Including module_utils file ansible_collections/kubernetes/core/plugins/module_utils/k8s/resource.py
Including module_utils file ansible/module_utils/urls.py
Including module_utils file ansible/module_utils/compat/typing.py
Including module_utils file ansible_collections/kubernetes/core/plugins/module_utils/k8s/runner.py
Including module_utils file ansible_collections/kubernetes/core/plugins/module_utils/k8s/service.py
Including module_utils file ansible/module_utils/common/dict_transformations.py
Including module_utils file ansible_collections/kubernetes/core/plugins/module_utils/apply.py
Including module_utils file ansible_collections/kubernetes/core/plugins/module_utils/common.py
Including module_utils file ansible_collections/kubernetes/core/plugins/module_utils/exceptions.py
Including module_utils file ansible_collections/kubernetes/core/plugins/module_utils/hashes.py
Including module_utils file ansible_collections/kubernetes/core/plugins/module_utils/k8s/waiter.py
Including module_utils file ansible_collections/kubernetes/core/plugins/module_utils/k8sdynamicclient.py
Including module_utils file ansible_collections/kubernetes/core/plugins/module_utils/selector.py
Including module_utils file ansible_collections/kubernetes/core/plugins/module_utils/version.py
Including module_utils file ansible_collections/kubernetes/core/plugins/module_utils/_version.py
Using module file /home/user1/.ansible/collections/ansible_collections/community/okd/plugins/modules/k8s.py
<localhost> PUT /home/user1/.ansible/tmp/ansible-local-295419_8a9imt/tmp278xio2s TO /home/user1/.ansible/tmp/ansible-tmp-1712586762.9948385-29764-140730930417156/AnsiballZ_k8s.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/user1/.ansible/tmp/ansible-tmp-1712586762.9948385-29764-140730930417156/ /home/user1/.ansible/tmp/ansible-tmp-1712586762.9948385-29764-140730930417156/AnsiballZ_k8s.py && sleep 0'
<localhost> EXEC /bin/sh -c 'sudo -H -S -n -u root /bin/sh -c '"'"'echo BECOME-SUCCESS-jboicwidygywbifurduwsuvajbcobivp ; /usr/bin/python3 /home/user1/.ansible/tmp/ansible-tmp-1712586762.9948385-29764-140730930417156/AnsiballZ_k8s.py'"'"' && sleep 0'
At the end of this output is when the playbook hangs. In the above output, I suspect the WARNINGS are a clue as to what’s wrong? Furthermore, the line,
redirecting (type: action) community.okd.k8s to kubernetes.core.k8s_info
shows that kubernetes.core.k8s_info
is being used in the background instead. Is that a clue?
Using kubernetes.core.k8s
In the above playbook, replacing community.okd.k8s
with kubernetes.core.k8s
, I get the following output for that task:
TASK [Create a k8s namespace] **************************************************************************************************************************************************************************************************
task path: /home/user1/ansible_project/ansible/playbooks/okd_deploy.yml:16
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: user1
<localhost> EXEC /bin/sh -c 'echo ~user1 && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/user1/.ansible/tmp `"&& mkdir "` echo /home/user1/.ansible/tmp/ansible-tmp-1712587473.9163046-30288-168059330956874 `" && echo ansible-tmp-1712587473.9163046-30288-168059330956874="` echo /home/user1/.ansible/tmp/ansible-tmp-1712587473.9163046-30288-168059330956874 `" ) && sleep 0'
Loading collection cloud.common from /home/user1/.ansible/collections/ansible_collections/cloud/common
[WARNING]: Collection cloud.common does not support Ansible version 2.13.10
Including module_utils file ansible/__init__.py
Including module_utils file ansible/module_utils/__init__.py
Including module_utils file ansible/module_utils/basic.py
Including module_utils file ansible/module_utils/_text.py
Including module_utils file ansible/module_utils/common/_collections_compat.py
Including module_utils file ansible/module_utils/common/__init__.py
Including module_utils file ansible/module_utils/common/_json_compat.py
Including module_utils file ansible/module_utils/common/_utils.py
Including module_utils file ansible/module_utils/common/arg_spec.py
Including module_utils file ansible/module_utils/common/file.py
Including module_utils file ansible/module_utils/common/locale.py
Including module_utils file ansible/module_utils/common/parameters.py
Including module_utils file ansible/module_utils/common/collections.py
Including module_utils file ansible/module_utils/common/process.py
Including module_utils file ansible/module_utils/common/sys_info.py
Including module_utils file ansible/module_utils/common/text/converters.py
Including module_utils file ansible/module_utils/common/text/__init__.py
Including module_utils file ansible/module_utils/common/text/formatters.py
Including module_utils file ansible/module_utils/common/validation.py
Including module_utils file ansible/module_utils/common/warnings.py
Including module_utils file ansible/module_utils/compat/selectors.py
Including module_utils file ansible/module_utils/compat/__init__.py
Including module_utils file ansible/module_utils/compat/_selectors2.py
Including module_utils file ansible/module_utils/compat/selinux.py
Including module_utils file ansible/module_utils/distro/__init__.py
Including module_utils file ansible/module_utils/distro/_distro.py
Including module_utils file ansible/module_utils/errors.py
Including module_utils file ansible/module_utils/parsing/convert_bool.py
Including module_utils file ansible/module_utils/parsing/__init__.py
Including module_utils file ansible/module_utils/pycompat24.py
Including module_utils file ansible/module_utils/six/__init__.py
Including module_utils file ansible_collections/kubernetes/core/plugins/module_utils/ansiblemodule.py
Including module_utils file ansible_collections/__init__.py
Including module_utils file ansible_collections/cloud/common/plugins/module_utils/turbo/module.py
Including module_utils file ansible_collections/cloud/__init__.py
Including module_utils file ansible_collections/cloud/common/__init__.py
Including module_utils file ansible_collections/cloud/common/plugins/__init__.py
Including module_utils file ansible_collections/cloud/common/plugins/module_utils/__init__.py
Including module_utils file ansible_collections/cloud/common/plugins/module_utils/turbo/__init__.py
Including module_utils file ansible_collections/cloud/common/plugins/module_utils/turbo/common.py
Including module_utils file ansible_collections/cloud/common/plugins/module_utils/turbo/exceptions.py
Including module_utils file ansible_collections/cloud/common/plugins/module_utils/turbo/server.py
Including module_utils file ansible_collections/kubernetes/__init__.py
Including module_utils file ansible_collections/kubernetes/core/__init__.py
Including module_utils file ansible_collections/kubernetes/core/plugins/__init__.py
Including module_utils file ansible_collections/kubernetes/core/plugins/module_utils/__init__.py
Including module_utils file ansible_collections/kubernetes/core/plugins/module_utils/args_common.py
Including module_utils file ansible_collections/kubernetes/core/plugins/module_utils/k8s/core.py
Including module_utils file ansible_collections/kubernetes/core/plugins/module_utils/k8s/__init__.py
Including module_utils file ansible_collections/kubernetes/core/plugins/module_utils/k8s/exceptions.py
Including module_utils file ansible_collections/kubernetes/core/plugins/module_utils/k8s/runner.py
Including module_utils file ansible_collections/kubernetes/core/plugins/module_utils/k8s/client.py
Including module_utils file ansible_collections/kubernetes/core/plugins/module_utils/client/discovery.py
Including module_utils file ansible_collections/kubernetes/core/plugins/module_utils/client/__init__.py
Including module_utils file ansible_collections/kubernetes/core/plugins/module_utils/client/resource.py
Including module_utils file ansible_collections/kubernetes/core/plugins/module_utils/k8s/resource.py
Including module_utils file ansible/module_utils/urls.py
Including module_utils file ansible/module_utils/compat/typing.py
Including module_utils file ansible_collections/kubernetes/core/plugins/module_utils/k8s/service.py
Including module_utils file ansible/module_utils/common/dict_transformations.py
Including module_utils file ansible_collections/kubernetes/core/plugins/module_utils/apply.py
Including module_utils file ansible_collections/kubernetes/core/plugins/module_utils/common.py
Including module_utils file ansible_collections/kubernetes/core/plugins/module_utils/exceptions.py
Including module_utils file ansible_collections/kubernetes/core/plugins/module_utils/hashes.py
Including module_utils file ansible_collections/kubernetes/core/plugins/module_utils/k8s/waiter.py
Including module_utils file ansible_collections/kubernetes/core/plugins/module_utils/k8sdynamicclient.py
Including module_utils file ansible_collections/kubernetes/core/plugins/module_utils/selector.py
Including module_utils file ansible_collections/kubernetes/core/plugins/module_utils/version.py
Including module_utils file ansible_collections/kubernetes/core/plugins/module_utils/_version.py
Using module file /home/user1/.ansible/collections/ansible_collections/kubernetes/core/plugins/modules/k8s.py
<localhost> PUT /home/user1/.ansible/tmp/ansible-local-30070o6x3avdo/tmp1ljrlm_y TO /home/user1/.ansible/tmp/ansible-tmp-1712587473.9163046-30288-168059330956874/AnsiballZ_k8s.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/user1/.ansible/tmp/ansible-tmp-1712587473.9163046-30288-168059330956874/ /home/user1/.ansible/tmp/ansible-tmp-1712587473.9163046-30288-168059330956874/AnsiballZ_k8s.py && sleep 0'
<localhost> EXEC /bin/sh -c 'sudo -H -S -n -u root /bin/sh -c '"'"'echo BECOME-SUCCESS-uooxpivyspevqswieidyovsyorucsaws ; /usr/bin/python3 /home/user1/.ansible/tmp/ansible-tmp-1712587473.9163046-30288-168059330956874/AnsiballZ_k8s.py'"'"' && sleep 0'
I’ve tried removing common module’s directory as well but no luck. I’m not sure what further information I can provide but please feel free to let me know if any. Really appreciate any help.
Thanks,