Skip to content

ModuleNotFoundError: no module named ansible_collections #827

Closed
@philfry

Description

@philfry

Some ansible collections won't run with mitogen due to mitogen being unable to find the corresponding module_utils:

  • community.general 2.5.1:
    • one_host
    • one_template
  • netbox.netbox 3.0.0:
    • nearly all modules from this collection

How to reproduce:

(note: to test whether or not ansible/mitogen is able to find the modules it is not necessary to provide valid module attributes)

git clone https://github.com/dw/mitogen.git
cat > ansible.cfg <<EOF
[defaults]
strategy_plugins = mitogen/ansible_mitogen/plugins/strategy
strategy = mitogen_linear
EOF
ansible-galaxy install netbox.netbox community.general
cat > test-netbox.yml <<EOF
---
- hosts: localhost
  gather_facts: no
  tasks:
    - netbox.netbox.netbox_virtual_machine:
EOF
cat > test-opennebula.yml <<EOF
---
- hosts: localhost
  gather_facts: no
  tasks:
    - community.general.one_host:
EOF
ansible-playbook test-netbox.yml
ansible-playbook test-opennebula.yml

Which version of Ansible are you running?

2.10.8

Is your version of Ansible patched in any way?

no.

Are you running with any custom modules, or module_utils loaded?

no.

Have you tried the latest master version from Git?

yes.

Do you have some idea of what the underlying problem may be?

the failed modules do not include from ansible.module_utils.basic import AnsibleModule:

grep -L 'import.*AnsibleModule' ~/.ansible/collections/ansible_collections/community/general/plugins/modules/cloud/opennebula/*py
grep -L 'import.*AnsibleModule' ~/.ansible/collections/ansible_collections/netbox/netbox/plugins/modules/*py

Other modules from community.general, for example community.general.one_vm work fine as they include this line.
By adding this line to the netbox.netbox modules mitogen is able to find the required module_utils.

Mention your host and target OS and versions

  • controller node: Fedora 33
  • managed node: CentOS 7

Mention your host and target Python versions

  • controller node: 3.9.4
  • managed node: 2.7.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    affects-0.3Issues related to 0.3.X Mitogen releasesbugCode feature that hinders desired execution outcome

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions