Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ansible #642

Open
kgfcoder6 opened this issue Aug 8, 2023 · 10 comments
Open

Ansible #642

kgfcoder6 opened this issue Aug 8, 2023 · 10 comments
Labels
needs_info Needs additional information from original reporter

Comments

@kgfcoder6
Copy link

SUMMARY

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ValueError: ansible_collections.kubernetes.core.plugins.module_utils.client.discovery.spec is None
fatal: [rancher01.test1.nbg]: FAILED! => {"msg": "Unexpected failure during module execution.", "stdout": ""}

The full traceback is:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/ansible/executor/task_executor.py", line 147, in run
res = self._execute()
File "/usr/local/lib/python3.6/dist-packages/ansible/executor/task_executor.py", line 665, in _execute
result = self._handler.run(task_vars=variables)
File "/opt/ansible/roles/external_collections/ansible_collections/kubernetes/core/plugins/action/k8s.py", line 398, in run
task_vars=task_vars,
File "/usr/local/lib/python3.6/dist-packages/ansible/plugins/action/init.py", line 825, in _execute_module
(module_style, shebang, module_data, module_path) = self._configure_module(module_name=module_name, module_args=module_args, task_vars=task_vars)
File "/usr/local/lib/python3.6/dist-packages/ansible/plugins/action/init.py", line 211, in _configure_module
**become_kwargs)
File "/usr/local/lib/python3.6/dist-packages/ansible/executor/module_common.py", line 1283, in modify_module
environment=environment)
File "/usr/local/lib/python3.6/dist-packages/ansible/executor/module_common.py", line 1120, in _find_module_utils
py_module_cache, zf)
File "/usr/local/lib/python3.6/dist-packages/ansible/executor/module_common.py", line 911, in recursive_finder
py_module_names, py_module_cache, zf)
File "/usr/local/lib/python3.6/dist-packages/ansible/executor/module_common.py", line 911, in recursive_finder
py_module_names, py_module_cache, zf)
File "/usr/local/lib/python3.6/dist-packages/ansible/executor/module_common.py", line 911, in recursive_finder
py_module_names, py_module_cache, zf)
File "/usr/local/lib/python3.6/dist-packages/ansible/executor/module_common.py", line 751, in recursive_finder
[os.path.join(*py_module_name[:-idx])])
File "/usr/local/lib/python3.6/dist-packages/ansible/executor/module_common.py", line 671, in init
self.get_source()
File "/usr/local/lib/python3.6/dist-packages/ansible/executor/module_common.py", line 687, in get_source
data = pkgutil.get_data(to_native(self._package_name), to_native(self._mod_name + '.py'))
File "/usr/lib/python3.6/pkgutil.py", line 616, in get_data
spec = importlib.util.find_spec(package)
File "/usr/lib/python3.6/importlib/util.py", line 102, in find_spec
raise ValueError('{}.spec is None'.format(name))
ValueError: ansible_collections.kubernetes.core.plugins.module_utils.client.discovery.spec is None
fatal: [rancher01.test1.nbg]: FAILED! => {
"msg": "Unexpected failure during module execution.",
"stdout": ""
}

ISSUE TYPE
  • Bug Report
COMPONENT NAME

kubernetes.core.k8s

ANSIBLE VERSION

COLLECTION VERSION
  from cryptography.exceptions import InvalidSignature
ansible 2.9.27
  config file = /opt/ansible/ansible.cfg
  configured module search path = ['/opt/ansible/ansible_plugins/modules']
  ansible python module location = /usr/local/lib/python3.6/dist-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.6.9 (default, Mar 10 2023, 16:46:00) [GCC 8.4.0]


CONFIGURATION
/usr/local/lib/python3.6/dist-packages/ansible/parsing/vault/__init__.py:44: CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python core team. Therefore, support for it is deprecated in cryptography. The next release of cryptography (40.0) will be the last to support Python 3.6.
  from cryptography.exceptions import InvalidSignature
ANSIBLE_SSH_RETRIES(/opt/ansible/ansible.cfg) = 5
ANY_ERRORS_FATAL(/opt/ansible/ansible.cfg) = True
CACHE_PLUGIN(/opt/ansible/ansible.cfg) = jsonfile
CACHE_PLUGIN_CONNECTION(/opt/ansible/ansible.cfg) = /tmp/ansible_facts
CACHE_PLUGIN_TIMEOUT(/opt/ansible/ansible.cfg) = 1000000
COLLECTIONS_PATHS(/opt/ansible/ansible.cfg) = ['/opt/ansible/roles/external_collections']
DEFAULT_ACTION_PLUGIN_PATH(/opt/ansible/ansible.cfg) = ['/opt/ansible/ansible_plugins/action_plugins']
DEFAULT_CALLBACK_PLUGIN_PATH(/opt/ansible/ansible.cfg) = ['/opt/ansible/ansible_plugins/callback_plugins']
DEFAULT_CALLBACK_WHITELIST(/opt/ansible/ansible.cfg) = ['profile_tasks']
DEFAULT_FILTER_PLUGIN_PATH(/opt/ansible/ansible.cfg) = ['/opt/ansible/ansible_plugins/filter_plugins']
DEFAULT_FORKS(/opt/ansible/ansible.cfg) = 10
DEFAULT_GATHERING(/opt/ansible/ansible.cfg) = smart
DEFAULT_INVENTORY_PLUGIN_PATH(/opt/ansible/ansible.cfg) = ['/opt/ansible/ansible_plugins/inventory_plugins']
DEFAULT_LOOKUP_PLUGIN_PATH(/opt/ansible/ansible.cfg) = ['/opt/ansible/ansible_plugins/lookup_plugins']
DEFAULT_MANAGED_STR(/opt/ansible/ansible.cfg) = Managed by Ansible
DEFAULT_MODULE_PATH(/opt/ansible/ansible.cfg) = ['/opt/ansible/ansible_plugins/modules']
DEFAULT_MODULE_UTILS_PATH(/opt/ansible/ansible.cfg) = ['/opt/ansible/ansible_plugins/module_utils']
DEFAULT_ROLES_PATH(/opt/ansible/ansible.cfg) = ['/opt/ansible/roles/internal']
DEFAULT_VAULT_IDENTITY_LIST(/opt/ansible/ansible.cfg) = ['dev@utils/vault_pass-client.py', 'prod@utils/vault_pass-client.py']
DEFAULT_VAULT_ID_MATCH(/opt/ansible/ansible.cfg) = True
INTERPRETER_PYTHON(/opt/ansible/ansible.cfg) = auto


OS / ENVIRONMENT

OS - Ubuntu 20
python 3.6
Ansible 2.9
rke_rancher_version: '2.6.3'
rke_version: 'v1.3.3'
rke_kubernetes_version: 'v1.21.7-rancher1-1'

STEPS TO REPRODUCE

If we run any simple playbook to create kubernetes namespace using the kubernetes.core.k8s collection, the error would reoccur and doesnot allow to use module to create namespace and gives error with ansible_collections/kubernetes/core/plugins/module_utils/client/disocovery.py and i didnot find any existing issue here and as i am trying to create a rke cluster in test environment replicating existing prod setup, need this to run on older versions as mentioned above, please help to fix dynamic discovery plugin as it continuously tells spec not found and not sure what to change.

  kubernetes.core.k8s:
    state: 'present'
    api_version: v1
    kind: Namespace
    name: monitoring

EXPECTED RESULTS

namespace should be created and dynamic module should be configured by the ansible collections

ACTUAL RESULTS

@gravesm
Copy link
Member

gravesm commented Aug 8, 2023

@kgfcoder6 which version of the collection are you using? Also, you are using a very old version of ansible. The current version is 2.15.

@gravesm gravesm added the needs_info Needs additional information from original reporter label Aug 8, 2023
@kgfcoder6
Copy link
Author

yes i am using old version of ansible, its 2.9.27
ansible --version
/usr/local/lib/python3.6/dist-packages/ansible/parsing/vault/init.py:44: CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python core team. Therefore, support for it is deprecated in cryptography. The next release of cryptography (40.0) will be the last to support Python 3.6.
from cryptography.exceptions import InvalidSignature
ansible 2.9.27
config file = /opt/ansible/ansible.cfg
configured module search path = ['/opt/ansible/ansible_plugins/modules']
ansible python module location = /usr/local/lib/python3.6/dist-packages/ansible
executable location = /usr/local/bin/ansible
python version = 3.6.9 (default, Mar 10 2023, 16:46:00) [GCC 8.4.0]

As i told i have a project requirement to build the rke cluster on this old version

@gravesm
Copy link
Member

gravesm commented Aug 8, 2023

I still need to know the version of the collection you are using to debug this. Since you are using an old version of ansible, you will have to look in the MANIFEST.json file where the collection is installed to get the version.

@kgfcoder6
Copy link
Author

cat MANIFEST.json
{
"collection_info": {
"namespace": "community",
"name": "kubernetes",
"version": "2.0.1",
"authors": [
"chouseknecht (https://github.com/chouseknecht)",
"geerlingguy (https://www.jeffgeerling.com/)",
"maxamillion (https://github.com/maxamillion)",
"jmontleon (https://github.com/jmontleon)",
"fabianvf (https://github.com/fabianvf)",
"willthames (https://github.com/willthames)",
"mmazur (https://github.com/mmazur)",
"jamescassell (https://github.com/jamescassell)"
],
"readme": "README.md",
"tags": [
"kubernetes",
"k8s",
"cloud",
"infrastructure",
"openshift",
"okd",
"cluster"
],
"description": "Kubernetes Collection for Ansible.",
"license": [],
"license_file": "LICENSE",
"dependencies": {
"kubernetes.core": ">=2.0.0"
},
"repository": "https://github.com/ansible-collections/community.kubernetes",
"documentation": "",
"homepage": "",
"issues": "https://github.com/ansible-collections/community.kubernetes/issues"
},
"file_manifest_file": {
"name": "FILES.json",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "0158009feef57d08f38ee8646123e61f6085d5838421fc5583249235f03731c8",
"format": 1
},
"format": 1

Its "version": "2.0.1"

@kgfcoder6
Copy link
Author

ALso I am unable to update the k8 plugin and getting below error

ansible-galaxy collection install kubernetes.core -vvv
ansible-galaxy [core 2.12.0]
config file = None
configured module search path = ['/home/prathap/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
ansible collection location = /home/prathap/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/bin/ansible-galaxy
python version = 3.10.6 (main, Mar 10 2023, 10:55:28) [GCC 11.3.0]
jinja version = 3.0.3
libyaml = True
No config file found; using defaults
Starting galaxy collection install process
Process install dependency map
ERROR! Unexpected Exception, this is probably a bug: CollectionDependencyProvider.find_matches() got an unexpected keyword argument 'identifier'
the full traceback was:

Traceback (most recent call last):
File "/usr/bin/ansible-galaxy", line 128, in
exit_code = cli.run()
File "/usr/lib/python3/dist-packages/ansible/cli/galaxy.py", line 567, in run
return context.CLIARGS'func'
File "/usr/lib/python3/dist-packages/ansible/cli/galaxy.py", line 86, in method_wrapper
return wrapped_method(*args, **kwargs)
File "/usr/lib/python3/dist-packages/ansible/cli/galaxy.py", line 1201, in execute_install
self._execute_install_collection(
File "/usr/lib/python3/dist-packages/ansible/cli/galaxy.py", line 1228, in _execute_install_collection
install_collections(
File "/usr/lib/python3/dist-packages/ansible/galaxy/collection/init.py", line 513, in install_collections
dependency_map = _resolve_depenency_map(
File "/usr/lib/python3/dist-packages/ansible/galaxy/collection/init.py", line 1327, in _resolve_depenency_map
return collection_dep_resolver.resolve(
File "/usr/lib/python3/dist-packages/resolvelib/resolvers.py", line 481, in resolve
state = resolution.resolve(requirements, max_rounds=max_rounds)
File "/usr/lib/python3/dist-packages/resolvelib/resolvers.py", line 348, in resolve
self._add_to_criteria(self.state.criteria, r, parent=None)
File "/usr/lib/python3/dist-packages/resolvelib/resolvers.py", line 147, in _add_to_criteria
matches = self._p.find_matches(
TypeError: CollectionDependencyProvider.find_matches() got an unexpected keyword argument 'identifier'

BUt this might be due to version issue and as I told I would not be able to update python and ansible versions, will try with higher rke versions but could you please suggest what changes has to be done to configure k8 plugins for this ansible ?

@gravesm
Copy link
Member

gravesm commented Aug 8, 2023

It looks like you are using ansible 2.12 here, which is no longer supported. I would strongly suggest using at least ansible 2.13, though preferably higher.

@kgfcoder6
Copy link
Author

sorry previously i was looking in community folder, I again checked kubernetes folder inside collections,

external_collections/ansible_collections/kubernetes/core$ cat MANIFEST.json
{
"collection_info": {
"namespace": "kubernetes",
"name": "core",
"version": "2.4.0",
"authors": [
"chouseknecht (https://github.com/chouseknecht)",
"geerlingguy (https://www.jeffgeerling.com/)",
"maxamillion (https://github.com/maxamillion)",
"jmontleon (https://github.com/jmontleon)",
"fabianvf (https://github.com/fabianvf)",
"willthames (https://github.com/willthames)",
"mmazur (https://github.com/mmazur)",
"jamescassell (https://github.com/jamescassell)"
],
"readme": "README.md",
"tags": [
"kubernetes",
"k8s",
"cloud",
"infrastructure",
"openshift",
"okd",
"cluster"
],
"description": "Kubernetes Collection for Ansible.",
"license": [],
"license_file": "LICENSE",
"dependencies": {},
"repository": "https://github.com/ansible-collections/kubernetes.core",
"documentation": "",
"homepage": "",
"issues": "https://github.com/ansible-collections/kubernetes.core/issues"
},
"file_manifest_file": {
"name": "FILES.json",
"ftype": "file",
"chksum_type": "sha256",
"chksum_sha256": "67908745863fefe0495eee77399178e88b89bb04a19fc728d2ac83a4d93abd1a",
"format": 1
},
"format": 1

and version is 2.4.0

@gravesm
Copy link
Member

gravesm commented Aug 8, 2023

I cannot reproduce this. Using the playbook you provided, python 3.6, ansible 2.9.27 and kubernetes.core 2.4.0 it works.

@kgfcoder6
Copy link
Author

but still i guess playbooks are taking old version and as you could see when i tried to update it said core 2.12 so i am really confused that even though inside kubernetes folder core says 2.4, it may be using 2.12 core and unable to update as it gives above error

@mossicrue
Copy link

mossicrue commented Oct 4, 2023

@kgfcoder6 just hitting your same bug in my playbook using kubernetes.core collection at version 2.4.0 for a 1.28.2 Kubernetes cluster

I workarounded the error by removing the 2.4.0 version of the collection and installing the 2.3.2

@gravesm if some other data are needed just ask :)

Ansible Version:

[root@bastion ansible]# ansible --version
ansible 2.9.27
  config file = /opt/ansible/ansible.cfg
  configured module search path = ['/root/.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, May 31 2023, 10:28:59) [GCC 8.5.0 20210514 (Red Hat 8.5.0-18)]

Ansible configuration:

[root@bastion ansible]# cat ansible.cfg 
  [defaults]
inventory      = ./inventory
roles_path     = ./roles
#interpreter_python = /usr/bin/python3
ansible_python_interpreter = /usr/bin/python3
private_key_file = /root/.ssh/ansible_rsa
host_key_checking = False
deprecation_warnings = False
display_skipped_hosts = False
# become = True
# become_method = sudo
# become_user = root

[ssh_connection]
ssh_args = -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null

The task that cause the error:

- name: Create secret
  kubernetes.core.k8s:
    state: present 
    kind: Secret
    definition: 
      apiVersion: v1
      kind: Secret 
      metadata:
        name: vault-token-auth
        namespace: default
        annotations:
          kubernetes.io/service-account.name: default
      type: kubernetes.io/service-account-token

EDIT: Tomorrow I will try also to redeploy the kubernetes cluster with fresh vm and test the playbook with the 2.4.0 collections

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs_info Needs additional information from original reporter
Projects
None yet
Development

No branches or pull requests

3 participants