Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

Could not find imported module support code #181

Open
beniyp opened this issue Jun 11, 2021 · 5 comments
Open

Could not find imported module support code #181

beniyp opened this issue Jun 11, 2021 · 5 comments

Comments

@beniyp
Copy link

beniyp commented Jun 11, 2021

Hi,

I ran into issues with installing and running this as a collection, but the modules work fine if I copy the modules and module_utils into my local ansible/plugin directories:

bash-4.4# ansible-galaxy collection install vmware.vcloud_director
[WARNING]: You are running the development version of Ansible. You should only run Ansible from "devel" if you are modifying the Ansible
engine, or trying out features under development. This is a rapidly changing source of code and can become unstable at any point.
Starting galaxy collection install process
Process install dependency map
ERROR! Failed to resolve the requested dependencies map. Could not satisfy the following requirements:

  • vmware.vcloud_director:* (direct request)

bash-4.4# ansible-galaxy collection install -r requirements.yml
[WARNING]: You are running the development version of Ansible. You should only run Ansible from "devel" if you are modifying the Ansible
engine, or trying out features under development. This is a rapidly changing source of code and can become unstable at any point.
Starting galaxy collection install process
Process install dependency map
Cloning into '/home/runner/.ansible/tmp/ansible-local-10707uryrtdy/tmp5gkfl8di/ansible-module-vcloud-director_d16tk1n'...
remote: Enumerating objects: 1864, done.
remote: Counting objects: 100% (285/285), done.
remote: Compressing objects: 100% (169/169), done.
remote: Total 1864 (delta 164), reused 192 (delta 86), pack-reused 1579
Receiving objects: 100% (1864/1864), 482.00 KiB | 2.31 MiB/s, done.
Resolving deltas: 100% (1085/1085), done.
Branch 'collection' set up to track remote branch 'collection' from 'origin'.
Switched to a new branch 'collection'
Starting collection install process
Installing 'vmware.vcloud_director:0.0.1' to '/home/runner/.ansible/collections/ansible_collections/vmware/vcloud_director'
Created collection for vmware.vcloud_director:0.0.1 at /home/runner/.ansible/collections/ansible_collections/vmware/vcloud_director
vmware.vcloud_director:0.0.1 was installed successfully

bash-4.4# cat requirements.yml

collections:

bash-4.4# ansible-galaxy collection list
[WARNING]: You are running the development version of Ansible. You should only run Ansible from "devel" if you are modifying the Ansible
engine, or trying out features under development. This is a rapidly changing source of code and can become unstable at any point.

/home/runner/.ansible/collections/ansible_collections

Collection Version


vmware.vcloud_director 0.0.1

/usr/share/ansible/collections/ansible_collections

Collection Version


amazon.aws 1.5.0
ansible.posix 1.2.0
ansible.windows 1.6.0
awx.awx 19.2.0
azure.azcollection 1.6.0
community.vmware 1.10.0
google.cloud 1.0.2
kubernetes.core 1.2.1
openstack.cloud 1.4.0
ovirt.ovirt 1.4.2
theforeman.foreman 2.1.0

Ran a simple playbook to list snapshot, and it erred out, but completes successfully if I copy the modules into /home/runner/.ansible/plugins/

Playbook sample:

  • name: test
    hosts: localhost
    tasks:
    • name: list vm snapshot
      vmware.vcloud_director.vcd_vapp_vm_snapshot:
      user: ansible_user
      ...

Error message:

fatal: [localhost]: FAILED! => {"msg": "Could not find imported module support code for ansible_collections.vmware.vcloud_director.plugins.modules.vcd_vapp_vm_snapshot. Looked for (['ansible.module_utils.vcd.VcdAnsibleModule', 'ansible.module_utils.vcd'])"}

bash-4.4# ls -ltr /home/runner/.ansible/collections/ansible_collections/vmware/vcloud_director/plugins/modules/vcd_vapp_vm_snapshot.py
-rw-r--r-- 1 root root 8766 Jun 11 01:17 /home/runner/.ansible/collections/ansible_collections/vmware/vcloud_director/plugins/modules/vcd_vapp_vm_snapshot.py

$ ansible --version

ansible [core 2.12.0.dev0]
config file = None
configured module search path = ['/home/runner/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python3.8/site-packages/ansible
ansible collection location = /home/runner/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/local/bin/ansible
python version = 3.8.3 (default, Aug 31 2020, 16:03:14) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]
jinja version = 2.10.3
libyaml = True

Please advise, thanks!

@mukultaneja
Copy link
Collaborator

@beniyp, these modules are not published at the galaxy server, may be that is why you are getting errors while installing them, could you please try installing from git repo once?

@beniyp
Copy link
Author

beniyp commented Jun 11, 2021

Hi @mukultaneja

Yep, it was downloaded and installed successfully via requirements.yml file using the git repository. However, ansible and awx's custom EE with the collections and dependencies installed, cannot find the imported module support code when I use the module in the playbook referencing the module as namespace.collection.module

ex.


  • name: test
    hosts: localhost
    tasks:
    • name: list vm snapshot
      vmware.vcloud_director.vcd_vapp_vm_snapshot:
      user: ansible
      org:

@mukultaneja
Copy link
Collaborator

@beniyp, does your issue still persist?

@beniyp
Copy link
Author

beniyp commented Aug 23, 2021

Hi @mukultaneja

The issue persists; however, I find the root cause and worked around it.

The problem is that the modules are not using the collection naming convention. For example, vcd_vapp_vm_snapshot.py with line "from ansible.module_utils.vcd import VcdAnsibleModule" should be replaced with "ansible_collections.vmware.vcloud_director.plugins.module_utils.vcd import VcdAnsibleModule"

Then I updated FILES.json, repackaged the collection and was able to install it into the Ansible Execution Environment. I hope this helps.

@user578
Copy link

user578 commented Oct 7, 2021

Any idea how can we fix it in the repository (without local patching)?
requirements.yml is the preferred way to install modules.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants