Repository navigation
Closed
Labels
affects-0.3Issues related to 0.3.X Mitogen releasesIssues related to 0.3.X Mitogen releasesbugCode feature that hinders desired execution outcomeCode feature that hinders desired execution outcome
Description
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.ymlWhich 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/*pyOther 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
Reacted by Christian Marg
Reacted by Christian Marg and 3nprob
Metadata
Metadata
Assignees
Labels
affects-0.3Issues related to 0.3.X Mitogen releasesIssues related to 0.3.X Mitogen releasesbugCode feature that hinders desired execution outcomeCode feature that hinders desired execution outcome
Activity
[-]ModuleNotFoundError: no module named ansible_collection.$stuff[/-][+]ModuleNotFoundError: no module named ansible_collections[/+]philfry commentedon Jul 1, 2021
looks like it doesn't matter what is being imported from
ansible.module_utilsals long as this library is mentioned.Tried with
netbox_virtual_machinefromnetbox.netboxversion 3.1.1.Case 1: Without any modifications ansible-mitogen complaints about
No module named 'ansible_collections'.Case 2: importing something from
ansible.module_utils=> this works.
Case 3: just adding a comment:
=> this also works. Wait, what? It doesn't even matter whether this line is commented out by
#or enclosed it with""".As I'm not deeply involved with mitogen, I'd like to get it clear:
Does mitogen scan the modules for phrases likefrom foo.barand does $stuff depending on its findings (scan_fromlist()is pretty suspicious)?philfry commentedon Jul 1, 2021
Looks like the
NewStylePlannerscans forfrom ansible.module_utils..Mitogen falls back to
OldStylePlannerif that line was not found. And afaict theOldStylePlannerdoesn't doscan_fromlistand stuff – and therefore fails with collections.fixes mitogen-hq#827
changelog entry for mitogen-hq#827
Zocker1999NET commentedon Jul 27, 2021
@philfry
I saw you implemented a fix. Does it work flawless? And, if so, do you mind creating a pull request?Nevermind, did not saw the PR #844 from yougarthwilliamson commentedon Aug 30, 2021
I've tested the PR #844 and it fixes the issue for us so far.