Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not find imported module support code for ansiblemodule (community kubernetes collection )

i installed the community kubernetes collection (https://galaxy.ansible.com/community/kubernetes)

run ansible-galaxy collection install community.kubernetes on my ansible machine and have this task to use the module:

- name: Create a dashboard service account
  kubernetes.core.k8s:
    kubeconfig: "{{ hostvars['master'].kubeconfig }}"
    state: present
    resource_definition:
      kind: ServiceAccount
      apiVersion: v1
      metadata:
        name: admin-user
        namespace: kubernetes-dashboard

and thats the output:

fatal: [master]: FAILED! => {"msg": "Could not find imported module support code for ansiblemodule.  Looked for either AnsibleTurboModule.py or module.py"}

ansible version:

ansible 2.9.9
  config file = /home/xx/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.7/dist-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.7.3 (default, Jan 22 2021, 20:04:44) [GCC 8.3.0]

OS:

PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

what do i need to fix this problem?

if you need more informations, let me know!

like image 961
Khalgrem Avatar asked Sep 15 '25 12:09

Khalgrem


1 Answers

I had this issue as well. Tracked it down to having not very well documented dependencies. The new kubernetes.core ansible package has a number of dependencies. The error you are getting is because of the AnsibleTurbo package. Even though the playbook doesn't use it by default, there is a reference that is unsatisfied. The following need to be installed on the host where your playbook is run:

ansible-galaxy collection install community.kubernetes
ansible-galaxy collection install cloud.common

That should solve the core problem you are having. You may run into another, where the kuberentes python API package needs to be installed on the targets.

Note: depending on how you define your hosts, you'll only need to install the pip package if you are trying to interact with the k8s API through the defined host. Installing the package locally and telling the k8s module to use localhost as the target should result in success if you have your kubeconfig locally, pointing to the remote cluster.

Here is what I added to my playbook to get the k8s module to work with the remotes:

- name: ensure python3 is installed
  become: yes
  ansible.builtin.package:
    name:
      - python3
      - python3-pip
    state: present

- name: install kubernetes pip package
  pip:
    name: kubernetes
    state: present
like image 74
Kyle Petryszak Avatar answered Sep 17 '25 11:09

Kyle Petryszak