ansible-collections / kubernetes.core

The collection includes a variety of Ansible content to help automate the management of applications in Kubernetes and OpenShift clusters, as well as the provisioning and maintenance of clusters themselves.
Other
216 stars 135 forks source link

msg: kubernetes >= 12.0.0 is required #507

Closed trotro closed 1 year ago

trotro commented 2 years ago
SUMMARY

After upgrading from Ansible 2.9 to Ansible 2.13 I have an error when running tasks using kubernetes.core.k8s. It says that a dependency is missing or on the wrong version but it is installed with the latest version, which is superior to the requirements.

ISSUE TYPE
COMPONENT NAME

kubernetes.core.k8s

ANSIBLE VERSION
$ ansible --version
ansible [core 2.13.3]
  config file = /opt/app-root/src/myrepo/ansible.cfg
  configured module search path = ['/opt/app-root/src/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules', '/opt/app-root/src/myrepo/library']
  ansible python module location = /usr/local/lib/python3.9/site-packages/ansible
  ansible collection location = /opt/app-root/src/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.9.7 (default, Sep 13 2021, 08:18:39) [GCC 8.5.0 20210514 (Red Hat 8.5.0-3)]
  jinja version = 3.1.2
  libyaml = True
COLLECTION VERSION
$ ansible-galaxy collection list kubernetes.core

# /usr/local/lib/python3.9/site-packages/ansible_collections
Collection      Version
--------------- -------
kubernetes.core 2.3.2
CONFIGURATION
ANY_ERRORS_FATAL(/opt/app-root/src/myrepo/ansible.cfg) = True
CALLBACKS_ENABLED(/opt/app-root/src/myrepo/ansible.cfg) = ['audit_trail', 'profile_tasks']
DEFAULT_CALLBACK_PLUGIN_PATH(/opt/app-root/src/myrepo/ansible.cfg) = ['/usr/share/ansible/plugins/callback', '/opt/app-root/src/myrepo/plugins']
DEFAULT_FORKS(/opt/app-root/src/myrepo/ansible.cfg) = 13
DEFAULT_GATHERING(/opt/app-root/src/myrepo/ansible.cfg) = explicit
DEFAULT_HOST_LIST(/opt/app-root/src/myrepo/ansible.cfg) = ['/opt/app-root/src/myrepo/inventory_dynamic.py']
DEFAULT_LOAD_CALLBACK_PLUGINS(/opt/app-root/src/myrepo/ansible.cfg) = True
DEFAULT_MODULE_PATH(/opt/app-root/src/myrepo/ansible.cfg) = ['/opt/app-root/src/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules', '/opt/app-root/src/myrepo/library']
DEFAULT_PRIVATE_KEY_FILE(/opt/app-root/src/myrepo/ansible.cfg) = /opt/app-root/src/.ssh/id_rsa
DEFAULT_REMOTE_USER(/opt/app-root/src/myrepo/ansible.cfg) = ansible
DEFAULT_ROLES_PATH(/opt/app-root/src/myrepo/ansible.cfg) = ['/opt/app-root/src/myrepo/roles/']
DEFAULT_STDOUT_CALLBACK(/opt/app-root/src/myrepo/ansible.cfg) = yaml
DEFAULT_VAULT_PASSWORD_FILE(/opt/app-root/src/myrepo/ansible.cfg) = /opt/app-root/src/myrepo/.secret
HOST_KEY_CHECKING(/opt/app-root/src/myrepo/ansible.cfg) = False
INVALID_TASK_ATTRIBUTE_FAILED(/opt/app-root/src/myrepo/ansible.cfg) = False
RETRY_FILES_SAVE_PATH(/opt/app-root/src/myrepo/ansible.cfg) = /opt/app-root/src/myrepo/.retry
TRANSFORM_INVALID_GROUP_CHARS(/opt/app-root/src/myrepo/ansible.cfg) = ignore
OS / ENVIRONMENT

$ cat /etc/redhat-release Red Hat Enterprise Linux release 8.6 (Ootpa) $ uname -a Linux 27a985eddbfe 3.10.0-1160.76.1.el7.x86_64 #1 SMP Tue Jul 26 14:15:37 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux $ python -m pip freeze | grep 'ansible\|kubernetes' ansible==6.3.0 ansible-bender==0.9.0 ansible-compat==2.2.0 ansible-core==2.13.3 ansible-lint==6.5.0 kubernetes==24.2.0

STEPS TO REPRODUCE

Run a playbook with task below

- name: K8S | Deploy volsync operator
  kubernetes.core.k8s:
    state: present
    definition: "{{ lookup('template', item + '.j2') }}"
    wait: true
    apply: true
  loop: "{{ volsync_operator_files }}"
EXPECTED RESULTS

The task is working and deploying the k8s resources.

ACTUAL RESULTS
ansible-playbook [core 2.13.3]
  config file = /opt/app-root/src/myrepo/ansible.cfg
  configured module search path = ['/opt/app-root/src/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules', '/opt/app-root/src/myrepo/library']
  ansible python module location = /usr/local/lib/python3.9/site-packages/ansible
  ansible collection location = /opt/app-root/src/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible-playbook
  python version = 3.9.7 (default, Sep 13 2021, 08:18:39) [GCC 8.5.0 20210514 (Red Hat 8.5.0-3)]
  jinja version = 3.1.2
  libyaml = True
Using /opt/app-root/src/myrepo/ansible.cfg as config file
setting up inventory plugins
host_list declined parsing /opt/app-root/src/myrepo/inventory_dynamic.py as it did not pass its verify_file() method
Set default localhost to localhost
Parsed /opt/app-root/src/myrepo/inventory_dynamic.py inventory source with script plugin
statically imported: /opt/app-root/src/myrepo/roles/ocp/ocp_prerequisite_load_vars/tasks/load_shell_vars.yml
statically imported: /opt/app-root/src/myrepo/roles/dev/dev_manage_cluster_definition/tasks/push_cluster_definition.yml
statically imported: /opt/app-root/src/myrepo/roles/dev/dev_manage_cluster_definition/tasks/pull_cluster_definition.yml
redirecting (type: modules) ansible.builtin.git_config to community.general.git_config
Loading collection community.general from /usr/local/lib/python3.9/site-packages/ansible_collections/community/general
redirecting (type: modules) community.general.git_config to community.general.source_control.git_config
statically imported: /opt/app-root/src/myrepo/roles/ocp/ocp_prerequisite_load_vars/tasks/load_vars.yml
statically imported: /opt/app-root/src/myrepo/roles/ocp/ocp_prerequisite_load_vars/tasks/load_ssh_vars.yml
statically imported: /opt/app-root/src/myrepo/roles/ocp/ocp_prerequisite_load_vars/tasks/load_ingress_vars.yml
statically imported: /opt/app-root/src/myrepo/roles/ocp/ocp_prerequisite_load_vars/tasks/load_audit_vars.yml
Loading collection kubernetes.core from /usr/local/lib/python3.9/site-packages/ansible_collections/kubernetes/core
statically imported: /opt/app-root/src/myrepo/roles/infra/infra_k8s_config/tasks/setup_infra_nodes.yml
statically imported: /opt/app-root/src/myrepo/roles/ocp/ocp_tls_api/tasks/set_custom_tls_profile.yml
statically imported: /opt/app-root/src/myrepo/roles/ocp/ocp_operator/tasks/operator_hub_config.yml
statically imported: /opt/app-root/src/myrepo/roles/ocp/ocp_operator/tasks/operator_mirror.yml
statically imported: /opt/app-root/src/myrepo/roles/ocp/ocp_storage_oadp/tasks/noobaa-setup.yml
statically imported: /opt/app-root/src/myrepo/roles/ocp/ocp_storage_trident/tasks/install_operator.yml
statically imported: /opt/app-root/src/myrepo/roles/ocp/ocp_storage_trident/tasks/setup_export_policy.yml
Loading collection netapp.ontap from /usr/local/lib/python3.9/site-packages/ansible_collections/netapp/ontap
statically imported: /opt/app-root/src/myrepo/roles/ocp/ocp_storage_trident_metrics/tasks/install_qtree_exporter.yml
statically imported: /opt/app-root/src/myrepo/roles/ocp/ocp_auth_rhsso/tasks/install_rhsso.yml
redirecting (type: modules) ansible.builtin.java_keystore to community.general.java_keystore
redirecting (type: modules) community.general.java_keystore to community.general.system.java_keystore
statically imported: /opt/app-root/src/myrepo/roles/ocp/ocp_auth_rhsso/tasks/check_if_cert_has_changed.yml
statically imported: /opt/app-root/src/myrepo/roles/ocp/ocp_auth_rhsso/tasks/install/setup_kerberos_keytab.yml
statically imported: /opt/app-root/src/myrepo/roles/ocp/ocp_auth_rhsso/tasks/configure_rhsso.yml
statically imported: /opt/app-root/src/myrepo/roles/ocp/ocp_auth_rhsso/tasks/config/configure_realm.yml
statically imported: /opt/app-root/src/myrepo/roles/ocp/ocp_auth_rhsso/tasks/config/configure_ldap_federation.yml
redirecting (type: modules) community.general.keycloak_client to community.general.identity.keycloak.keycloak_client
redirecting (type: modules) community.general.keycloak_client to community.general.identity.keycloak.keycloak_client
statically imported: /opt/app-root/src/myrepo/roles/ocp/ocp_auth_rhsso/tasks/config/enable_mfa_x509.yml
redirecting (type: modules) community.general.htpasswd to community.general.web_infrastructure.htpasswd
redirecting (type: modules) community.general.htpasswd to community.general.web_infrastructure.htpasswd
statically imported: /opt/app-root/src/myrepo/roles/ocp/ocp_logging/tasks/splunk_forwarder.yml
statically imported: /opt/app-root/src/myrepo/roles/ocp/ocp_hardening_compliance/tasks/cleanup.yml
redirecting (type: modules) ansible.builtin.k8s to kubernetes.core.k8s
redirecting (type: modules) ansible.builtin.k8s to kubernetes.core.k8s
redirecting (type: modules) ansible.builtin.k8s to kubernetes.core.k8s
redirecting (type: modules) ansible.builtin.k8s to kubernetes.core.k8s
redirecting (type: modules) ansible.builtin.k8s_info to kubernetes.core.k8s_info
redirecting (type: modules) ansible.builtin.k8s_info to kubernetes.core.k8s_info
redirecting (type: modules) ansible.builtin.k8s_info to kubernetes.core.k8s_info
redirecting (type: modules) ansible.builtin.k8s to kubernetes.core.k8s
Loading collection ansible.posix from /usr/local/lib/python3.9/site-packages/ansible_collections/ansible/posix
redirecting (type: callback) ansible.builtin.yaml to community.general.yaml
redirecting (type: callback) ansible.builtin.yaml to community.general.yaml
Loading callback plugin community.general.yaml of type stdout, v2.0 from /usr/local/lib/python3.9/site-packages/ansible_collections/community/general/plugins/callback/yaml.py
redirecting (type: callback) ansible.builtin.profile_tasks to ansible.posix.profile_tasks
Loading callback plugin audit_trail of type aggregate, v2.0 from /opt/app-root/src/myrepo/plugins/audit_trail.py
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.
Loading callback plugin ansible.posix.profile_tasks of type aggregate, v2.0 from /usr/local/lib/python3.9/site-packages/ansible_collections/ansible/posix/plugins/callback/profile_tasks.py

PLAYBOOK: install.yml *****************************************************************************************************************************************************************************************************************
Positional arguments: playbooks/install.yml
verbosity: 4
private_key_file: /opt/app-root/src/.ssh/id_rsa
remote_user: ansible
connection: smart
timeout: 10
become_method: sudo
inventory: ('/opt/app-root/src/myrepo/inventory_dynamic.py',)
forks: 13
3 plays in playbooks/install.yml
(...)
META: ran handlers
TASK [volsync : K8S | Deploy volsync operator] *********************************************************************************************************************************************************************************
task path: /opt/app-root/src/myrepo/roles/volsync/tasks/main.yml:13
Tuesday 06 September 2022  14:24:46 +0000 (0:00:00.036)       0:00:45.442 *****
File lookup using /opt/app-root/src/myrepo/roles/volsync/templates/volsync-subscription.yml.j2 as file
<myhost.tld> ESTABLISH SSH CONNECTION FOR USER: openshift
<myhost.tld> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=10m -o StrictHostKeyChecking=no -o 'IdentityFile="/opt/app-root/src/.ssh/id_rsa"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="openshift"' -o ConnectTimeout=10 -o 'ControlPath="/opt/app-root/src/.ansible/cp/1f94d96fbf"' myhost.tld '/bin/sh -c '"'"'echo ~openshift && sleep 0'"'"''
<myhost.tld> (0, b'/home/openshift\n', b"OpenSSH_8.0p1, OpenSSL 1.1.1k  FIPS 25 Mar 2021\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug3: /etc/ssh/ssh_config line 52: Including file /etc/ssh/ssh_config.d/05-redhat.conf depth 0\r\ndebug1: Reading configuration data /etc/ssh/ssh_config.d/05-redhat.conf\r\ndebug2: checking match for 'final all' host myhost.tld originally myhost.tld\r\ndebug3: /etc/ssh/ssh_config.d/05-redhat.conf line 3: not matched 'final'\r\ndebug2: match not found\r\ndebug3: /etc/ssh/ssh_config.d/05-redhat.conf line 5: Including file /etc/crypto-policies/back-ends/openssh.config depth 1 (parse only)\r\ndebug1: Reading configuration data /etc/crypto-policies/back-ends/openssh.config\r\ndebug3: gss kex names ok: [gss-curve25519-sha256-,gss-nistp256-sha256-,gss-group14-sha256-,gss-group16-sha512-,gss-gex-sha1-,gss-group14-sha1-]\r\ndebug3: kex names ok: [curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1]\r\ndebug1: configuration requests final Match pass\r\ndebug1: re-parsing configuration\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug3: /etc/ssh/ssh_config line 52: Including file /etc/ssh/ssh_config.d/05-redhat.conf depth 0\r\ndebug1: Reading configuration data /etc/ssh/ssh_config.d/05-redhat.conf\r\ndebug2: checking match for 'final all' host myhost.tld originally myhost.tld\r\ndebug3: /etc/ssh/ssh_config.d/05-redhat.conf line 3: matched 'final'\r\ndebug2: match found\r\ndebug3: /etc/ssh/ssh_config.d/05-redhat.conf line 5: Including file /etc/crypto-policies/back-ends/openssh.config depth 1\r\ndebug1: Reading configuration data /etc/crypto-policies/back-ends/openssh.config\r\ndebug3: gss kex names ok: [gss-curve25519-sha256-,gss-nistp256-sha256-,gss-group14-sha256-,gss-group16-sha512-,gss-gex-sha1-,gss-group14-sha1-]\r\ndebug3: kex names ok: [curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1]\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 1995\r\ndebug3: mux_client_request_session: session request sent\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\n")
<myhost.tld> ESTABLISH SSH CONNECTION FOR USER: openshift
<myhost.tld> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=10m -o StrictHostKeyChecking=no -o 'IdentityFile="/opt/app-root/src/.ssh/id_rsa"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="openshift"' -o ConnectTimeout=10 -o 'ControlPath="/opt/app-root/src/.ansible/cp/1f94d96fbf"' myhost.tld '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo /home/openshift/.ansible/tmp `"&& mkdir "` echo /home/openshift/.ansible/tmp/ansible-tmp-1662474286.8818254-2004-150084350372755 `" && echo ansible-tmp-1662474286.8818254-2004-150084350372755="` echo /home/openshift/.ansible/tmp/ansible-tmp-1662474286.8818254-2004-150084350372755 `" ) && sleep 0'"'"''
<myhost.tld> (0, b'ansible-tmp-1662474286.8818254-2004-150084350372755=/home/openshift/.ansible/tmp/ansible-tmp-1662474286.8818254-2004-150084350372755\n', b"OpenSSH_8.0p1, OpenSSL 1.1.1k  FIPS 25 Mar 2021\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug3: /etc/ssh/ssh_config line 52: Including file /etc/ssh/ssh_config.d/05-redhat.conf depth 0\r\ndebug1: Reading configuration data /etc/ssh/ssh_config.d/05-redhat.conf\r\ndebug2: checking match for 'final all' host myhost.tld originally myhost.tld\r\ndebug3: /etc/ssh/ssh_config.d/05-redhat.conf line 3: not matched 'final'\r\ndebug2: match not found\r\ndebug3: /etc/ssh/ssh_config.d/05-redhat.conf line 5: Including file /etc/crypto-policies/back-ends/openssh.config depth 1 (parse only)\r\ndebug1: Reading configuration data /etc/crypto-policies/back-ends/openssh.config\r\ndebug3: gss kex names ok: [gss-curve25519-sha256-,gss-nistp256-sha256-,gss-group14-sha256-,gss-group16-sha512-,gss-gex-sha1-,gss-group14-sha1-]\r\ndebug3: kex names ok: [curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1]\r\ndebug1: configuration requests final Match pass\r\ndebug1: re-parsing configuration\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug3: /etc/ssh/ssh_config line 52: Including file /etc/ssh/ssh_config.d/05-redhat.conf depth 0\r\ndebug1: Reading configuration data /etc/ssh/ssh_config.d/05-redhat.conf\r\ndebug2: checking match for 'final all' host myhost.tld originally myhost.tld\r\ndebug3: /etc/ssh/ssh_config.d/05-redhat.conf line 3: matched 'final'\r\ndebug2: match found\r\ndebug3: /etc/ssh/ssh_config.d/05-redhat.conf line 5: Including file /etc/crypto-policies/back-ends/openssh.config depth 1\r\ndebug1: Reading configuration data /etc/crypto-policies/back-ends/openssh.config\r\ndebug3: gss kex names ok: [gss-curve25519-sha256-,gss-nistp256-sha256-,gss-group14-sha256-,gss-group16-sha512-,gss-gex-sha1-,gss-group14-sha1-]\r\ndebug3: kex names ok: [curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1]\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 1995\r\ndebug3: mux_client_request_session: session request sent\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\n")
Loading collection cloud.common from /usr/local/lib/python3.9/site-packages/ansible_collections/cloud/common
Using module file /usr/local/lib/python3.9/site-packages/ansible_collections/kubernetes/core/plugins/modules/k8s.py
Pipelining is enabled.
<myhost.tld> ESTABLISH SSH CONNECTION FOR USER: openshift
<myhost.tld> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=10m -o StrictHostKeyChecking=no -o 'IdentityFile="/opt/app-root/src/.ssh/id_rsa"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="openshift"' -o ConnectTimeout=10 -o 'ControlPath="/opt/app-root/src/.ansible/cp/1f94d96fbf"' myhost.tld '/bin/sh -c '"'"'/usr/bin/python && sleep 0'"'"''
<myhost.tld> (1, b'\n{"msg": "kubernetes >= 12.0.0 is required", "failed": true, "invocation": {"module_args": {"force": false, "wait_sleep": 5, "label_selectors": null, "server_side_apply": null, "impersonate_groups": null, "apply": true, "client_key": null, "password": null, "no_proxy": null, "namespace": null, "resource_definition": "---\\napiVersion: operators.coreos.com/v1alpha1\\nkind: Subscription\\nmetadata:\\n  labels:\\n    operators.coreos.com/volsync-product.openshift-operators: \'\'\\n    \\n  name: volsync-product\\n  namespace: openshift-operators\\nspec:\\n  channel: stable\\n  installPlanApproval: Manual\\n  name: volsync-product\\n  source: redhat-operators\\n  sourceNamespace: openshift-marketplace\\n  startingCSV: volsync-product.v0.4.1\\n...\\n", "state": "present", "template": null, "continue_on_error": false, "api_key": null, "client_cert": null, "api_version": "v1", "username": null, "ca_cert": null, "definition": "---\\napiVersion: operators.coreos.com/v1alpha1\\nkind: Subscription\\nmetadata:\\n  labels:\\n    operators.coreos.com/volsync-product.openshift-operators: \'\'\\n    \\n  name: volsync-product\\n  namespace: openshift-operators\\nspec:\\n  channel: stable\\n  installPlanApproval: Manual\\n  name: volsync-product\\n  source: redhat-operators\\n  sourceNamespace: openshift-marketplace\\n  startingCSV: volsync-product.v0.4.1\\n...\\n", "wait_condition": null, "generate_name": null, "host": null, "wait_timeout": 120, "proxy": null, "proxy_headers": null, "validate": null, "persist_config": null, "wait": true, "append_hash": false, "src": null, "kind": null, "name": null, "delete_options": null, "kubeconfig": null, "impersonate_user": null, "context": null, "validate_certs": null, "merge_type": null}}}\n', b"OpenSSH_8.0p1, OpenSSL 1.1.1k  FIPS 25 Mar 2021\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug3: /etc/ssh/ssh_config line 52: Including file /etc/ssh/ssh_config.d/05-redhat.conf depth 0\r\ndebug1: Reading configuration data /etc/ssh/ssh_config.d/05-redhat.conf\r\ndebug2: checking match for 'final all' host myhost.tld originally myhost.tld\r\ndebug3: /etc/ssh/ssh_config.d/05-redhat.conf line 3: not matched 'final'\r\ndebug2: match not found\r\ndebug3: /etc/ssh/ssh_config.d/05-redhat.conf line 5: Including file /etc/crypto-policies/back-ends/openssh.config depth 1 (parse only)\r\ndebug1: Reading configuration data /etc/crypto-policies/back-ends/openssh.config\r\ndebug3: gss kex names ok: [gss-curve25519-sha256-,gss-nistp256-sha256-,gss-group14-sha256-,gss-group16-sha512-,gss-gex-sha1-,gss-group14-sha1-]\r\ndebug3: kex names ok: [curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1]\r\ndebug1: configuration requests final Match pass\r\ndebug1: re-parsing configuration\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug3: /etc/ssh/ssh_config line 52: Including file /etc/ssh/ssh_config.d/05-redhat.conf depth 0\r\ndebug1: Reading configuration data /etc/ssh/ssh_config.d/05-redhat.conf\r\ndebug2: checking match for 'final all' host myhost.tld originally myhost.tld\r\ndebug3: /etc/ssh/ssh_config.d/05-redhat.conf line 3: matched 'final'\r\ndebug2: match found\r\ndebug3: /etc/ssh/ssh_config.d/05-redhat.conf line 5: Including file /etc/crypto-policies/back-ends/openssh.config depth 1\r\ndebug1: Reading configuration data /etc/crypto-policies/back-ends/openssh.config\r\ndebug3: gss kex names ok: [gss-curve25519-sha256-,gss-nistp256-sha256-,gss-group14-sha256-,gss-group16-sha512-,gss-gex-sha1-,gss-group14-sha1-]\r\ndebug3: kex names ok: [curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1]\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 1995\r\ndebug3: mux_client_request_session: session request sent\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 1\r\n")
<myhost.tld> Failed to connect to the host via ssh: OpenSSH_8.0p1, OpenSSL 1.1.1k  FIPS 25 Mar 2021
debug1: Reading configuration data /etc/ssh/ssh_config
debug3: /etc/ssh/ssh_config line 52: Including file /etc/ssh/ssh_config.d/05-redhat.conf depth 0
debug1: Reading configuration data /etc/ssh/ssh_config.d/05-redhat.conf
debug2: checking match for 'final all' host myhost.tld originally myhost.tld
debug3: /etc/ssh/ssh_config.d/05-redhat.conf line 3: not matched 'final'
debug2: match not found
debug3: /etc/ssh/ssh_config.d/05-redhat.conf line 5: Including file /etc/crypto-policies/back-ends/openssh.config depth 1 (parse only)
debug1: Reading configuration data /etc/crypto-policies/back-ends/openssh.config
debug3: gss kex names ok: [gss-curve25519-sha256-,gss-nistp256-sha256-,gss-group14-sha256-,gss-group16-sha512-,gss-gex-sha1-,gss-group14-sha1-]
debug3: kex names ok: [curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1]
debug1: configuration requests final Match pass
debug1: re-parsing configuration
debug1: Reading configuration data /etc/ssh/ssh_config
debug3: /etc/ssh/ssh_config line 52: Including file /etc/ssh/ssh_config.d/05-redhat.conf depth 0
debug1: Reading configuration data /etc/ssh/ssh_config.d/05-redhat.conf
debug2: checking match for 'final all' host myhost.tld originally myhost.tld
debug3: /etc/ssh/ssh_config.d/05-redhat.conf line 3: matched 'final'
debug2: match found
debug3: /etc/ssh/ssh_config.d/05-redhat.conf line 5: Including file /etc/crypto-policies/back-ends/openssh.config depth 1
debug1: Reading configuration data /etc/crypto-policies/back-ends/openssh.config
debug3: gss kex names ok: [gss-curve25519-sha256-,gss-nistp256-sha256-,gss-group14-sha256-,gss-group16-sha512-,gss-gex-sha1-,gss-group14-sha1-]
debug3: kex names ok: [curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1]
debug1: auto-mux: Trying existing master
debug2: fd 3 setting O_NONBLOCK
debug2: mux_client_hello_exchange: master version 4
debug3: mux_client_forwards: request forwardings: 0 local, 0 remote
debug3: mux_client_request_session: entering
debug3: mux_client_request_alive: entering
debug3: mux_client_request_alive: done pid = 1995
debug3: mux_client_request_session: session request sent
debug3: mux_client_read_packet: read header failed: Broken pipe
debug2: Received exit status from master 1
<myhost.tld> ESTABLISH SSH CONNECTION FOR USER: openshift
<myhost.tld> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=10m -o StrictHostKeyChecking=no -o 'IdentityFile="/opt/app-root/src/.ssh/id_rsa"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="openshift"' -o ConnectTimeout=10 -o 'ControlPath="/opt/app-root/src/.ansible/cp/1f94d96fbf"' myhost.tld '/bin/sh -c '"'"'rm -f -r /home/openshift/.ansible/tmp/ansible-tmp-1662474286.8818254-2004-150084350372755/ > /dev/null 2>&1 && sleep 0'"'"''
<myhost.tld> (0, b'', b"OpenSSH_8.0p1, OpenSSL 1.1.1k  FIPS 25 Mar 2021\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug3: /etc/ssh/ssh_config line 52: Including file /etc/ssh/ssh_config.d/05-redhat.conf depth 0\r\ndebug1: Reading configuration data /etc/ssh/ssh_config.d/05-redhat.conf\r\ndebug2: checking match for 'final all' host myhost.tld originally myhost.tld\r\ndebug3: /etc/ssh/ssh_config.d/05-redhat.conf line 3: not matched 'final'\r\ndebug2: match not found\r\ndebug3: /etc/ssh/ssh_config.d/05-redhat.conf line 5: Including file /etc/crypto-policies/back-ends/openssh.config depth 1 (parse only)\r\ndebug1: Reading configuration data /etc/crypto-policies/back-ends/openssh.config\r\ndebug3: gss kex names ok: [gss-curve25519-sha256-,gss-nistp256-sha256-,gss-group14-sha256-,gss-group16-sha512-,gss-gex-sha1-,gss-group14-sha1-]\r\ndebug3: kex names ok: [curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1]\r\ndebug1: configuration requests final Match pass\r\ndebug1: re-parsing configuration\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug3: /etc/ssh/ssh_config line 52: Including file /etc/ssh/ssh_config.d/05-redhat.conf depth 0\r\ndebug1: Reading configuration data /etc/ssh/ssh_config.d/05-redhat.conf\r\ndebug2: checking match for 'final all' host myhost.tld originally myhost.tld\r\ndebug3: /etc/ssh/ssh_config.d/05-redhat.conf line 3: matched 'final'\r\ndebug2: match found\r\ndebug3: /etc/ssh/ssh_config.d/05-redhat.conf line 5: Including file /etc/crypto-policies/back-ends/openssh.config depth 1\r\ndebug1: Reading configuration data /etc/crypto-policies/back-ends/openssh.config\r\ndebug3: gss kex names ok: [gss-curve25519-sha256-,gss-nistp256-sha256-,gss-group14-sha256-,gss-group16-sha512-,gss-gex-sha1-,gss-group14-sha1-]\r\ndebug3: kex names ok: [curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1]\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 1995\r\ndebug3: mux_client_request_session: session request sent\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\n")
failed: [myhost] (item=volsync-subscription.yml) => changed=false
  ansible_loop_var: item
  invocation:
    module_args:
      api_key: null
      api_version: v1
      append_hash: false
      apply: true
      ca_cert: null
      client_cert: null
      client_key: null
      context: null
      continue_on_error: false
      definition: |-
        ---
        apiVersion: operators.coreos.com/v1alpha1
        kind: Subscription
        metadata:
          labels:
            operators.coreos.com/volsync-product.openshift-operators: ''
          name: volsync-product
          namespace: openshift-operators
        spec:
          channel: stable
          installPlanApproval: Manual
          name: volsync-product
          source: redhat-operators
          sourceNamespace: openshift-marketplace
          startingCSV: volsync-product.v0.4.1
        ...
      delete_options: null
      force: false
      generate_name: null
      host: null
      impersonate_groups: null
      impersonate_user: null
      kind: null
      kubeconfig: null
      label_selectors: null
      merge_type: null
      name: null
      namespace: null
      no_proxy: null
      password: null
      persist_config: null
      proxy: null
      proxy_headers: null
      resource_definition: |-
        ---
        apiVersion: operators.coreos.com/v1alpha1
        kind: Subscription
        metadata:
          labels:
            operators.coreos.com/volsync-product.openshift-operators: ''
          name: volsync-product
          namespace: openshift-operators
        spec:
          channel: stable
          installPlanApproval: Manual
          name: volsync-product
          source: redhat-operators
          sourceNamespace: openshift-marketplace
          startingCSV: volsync-product.v0.4.1
        ...
      delete_options: null
      force: false
      generate_name: null
      host: null
      impersonate_groups: null
      impersonate_user: null
      kind: null
      kubeconfig: null
      label_selectors: null
      merge_type: null
      name: null
      namespace: null
      no_proxy: null
      password: null
      persist_config: null
      proxy: null
      proxy_headers: null
      resource_definition: |-
        ---
        apiVersion: operators.coreos.com/v1alpha1
        kind: Subscription
        metadata:
          labels:
            operators.coreos.com/volsync-product.openshift-operators: ''k
          name: volsync-product
          namespace: openshift-operators
        spec:
          channel: stable
          installPlanApproval: Manual
          name: volsync-product
          source: redhat-operators
          sourceNamespace: openshift-marketplace
          startingCSV: volsync-product.v0.4.1
        ...
      server_side_apply: null
      src: null
      state: present
      template: null
      username: null
      validate: null
      validate_certs: null
      wait: true
      wait_condition: null
      wait_sleep: 5
      wait_timeout: 120
  item: volsync-subscription.yml
  msg: kubernetes >= 12.0.0 is required

It seems the check_library_version function is not using the same code as the other calls to LooseVersion like the one line 228. I'm not good enough in Python to say for sure, but that may be an hint.

gravesm commented 2 years ago

@trotro You need to make sure that the python instance on the remote node has kubernetes installed.

GannonTdW commented 2 years ago

Hello, I have the same issue with ansible-core version 2.12.6

I am confuse, because the lastest kubernetes version is 1.25 ( see kubenetes release)

And yes, the remote node (AlmaLinux 8.6 for me) has kubernetes and python3-kubernetes installed.

For information:

# kubeadm version
kubeadm version: &version.Info{Major:"1", Minor:"25", GitVersion:"v1.25.0", GitCommit:"a866cbe2e5bbaa01cfd5e969aa3e033f3282a8a2", GitTreeState:"clean", BuildDate:"2022-08-23T17:43:25Z", GoVersion:"go1.19", Compiler:"gc", Platform:"linux/amd64"}
# kubectl get nodes -o wide
NAME             STATUS   ROLES           AGE   VERSION   INTERNAL-IP   EXTERNAL-IP   OS-IMAGE                    KERNEL-VERSION                 CONTAINER-RUNTIME
k8s-master-1   Ready    control-plane   51m   v1.25.0   10.0.0.1   <none>        AlmaLinux 8.6 (Sky Tiger)   4.18.0-372.16.1.el8_6.x86_64   containerd://1.6.8
k8s-worker-1   Ready    worker          50m   v1.25.0   10.0.0.2   <none>        AlmaLinux 8.6 (Sky Tiger)   4.18.0-372.16.1.el8_6.x86_64   containerd://1.6.8
k8s-worker-2   Ready    worker          50m   v1.25.0   10.0.0.3   <none>        AlmaLinux 8.6 (Sky Tiger)   4.18.0-372.16.1.el8_6.x86_64   containerd://1.6.8
gravesm commented 2 years ago

If you have confirmed that the remote python has all the required dependencies installed, you can try setting the ansible_python_interpreter to ensure the correct interpreter is being used: https://docs.ansible.com/ansible/latest/reference_appendices/interpreter_discovery.html

trotro commented 1 year ago

If you have confirmed that the remote python has all the required dependencies installed, you can try setting the ansible_python_interpreter to ensure the correct interpreter is being used: https://docs.ansible.com/ansible/latest/reference_appendices/interpreter_discovery.html

Sorry for the late reply. You spotted the cause. The interpreter on the remote was not the good one. Thank you.