Open ccravens opened 3 years ago
should this also happen with any collection?
[mux 39653] 15:04:30.305273 D mitogen.[****.sudo.postgres]: Dispatcher: Message(5, 2091, 0, 101, 1003, b'\x80\x02(X"\x00\x00\x00vlad-40202-7f348108f740-24ce69cb0aq\x00X\x16\x00\x00\x00a'..2339) -> {'rc': 1, 'stdout': '', 'stderr': 'Traceback (most recent call last):
File "master:/usr/local/lib/python3.8/dist-packages/ansible_mitogen/runner.py", line 975, in _run
self._run_code(code, mod)
File "master:/usr/local/lib/python3.8/dist-packages/ansible_mitogen/runner.py", line 939, in _run_code
exec(code, vars(mod))
File "master:/home/***/dev/ansible/collections/ansible_collections/community/general/plugins/modules/postgresql_user.py", line 273, in <module>
ModuleNotFoundError: No module named \'ansible_collections.community.general.plugins\'
'}
please confirm that any collection support is still broken in 522085ab35009a41f41ce8a17c52b4920dadcdba
@badfiles do you have that collection installed? Collection support was added in #715. Does it work for you without Mitogen?
yes, w/o mitogen collections work great we have collections in common code repo, so collections appear locally in ../collections/ansible_collections/ while playbooks are in ../
I too, am experiencing this. Using ansible 2.10.6, Mitogen 0.3.0rc1. Attempting to use community.general.docker_compose:
in a role. Results in:
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ModuleNotFoundError: No module named 'ansible_collections'
fatal: [myserver]: FAILED! => {"changed": false, "module_stderr": "", "module_stdout": "Traceback (most recent call last):\r\n File \"/home/kpoorman/.ansible/tmp/ansible_mitogen_runner_t9dtaaxl/docker_compose.py\", line 485, in <module>\r\n from ansible_collections.community.docker.plugins.module_utils.common import (\r\nModuleNotFoundError: No module named 'ansible_collections'\r\n", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
yes, w/o mitogen collections work great we have collections in common code repo, so collections appear locally in ../collections/ansible_collections/ while playbooks are in ../
out of curiosity, are you running ansible in a python virtual env? I am, and I'm wondering if mitogen is looking in the wrong spot for the collection?
hmmm good point, yes I believe I'm running a python 3.8 that's installed by anaconda
I’m running a 3.7, but the venv is in /opt/venv/
I wonder where mitogen is looking for collections? On Feb 5, 2021, 2:45 PM -0500, Chad Cravens notifications@github.com, wrote:
hmmm good point, yes I believe I'm running a python 3.8 that's installed by anaconda — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.
i'm running 3.8 installed as regular system binary
@badfiles @codefriar It's possible Mitogen is looking in the wrong place then. It uses list_collection_dirs
from Ansible here: https://github.com/ansible/ansible/blob/v2.10.0/lib/ansible/collections/list.py#L49 to find collections to use during job runs.
yep, setting https://docs.ansible.com/ansible/latest/reference_appendices/config.html#collections-paths in config helped, thanks
@s1113950 Is it possible to auto search the folder collections
? Currently, Ansible allows this and works with it as per https://docs.ansible.com/ansible/latest/user_guide/collections_using.html#installing-collections
Without mitogen it works w/o error, with mitogen it complains that it cannot find the collection.
Adding: collections_paths = ~/.ansible/collections:/usr/share/ansible/collections:collections
fixes the issue but if the default paths change I will also need to adjust that. If you need more information please let me know.
It should be possible I think. Mitogen finds collections via the Ansible function list_collection_dirs()
here: https://github.com/mitogen-hq/mitogen/blob/v0.3.0rc1/ansible_mitogen/planner.py#L569 , maybe there's a config setting we need to set to have it autosearch the collections
folder 🤔
I'm also affected by the inability to find any collection (including those bundled) when installed in a venv. I noticed the collections-scan-sys-path (default True) which allows for this, I presume, but fails with Mitogen installed (0.3.0rc1).
Having it to point to an installation-specific path (different for every venv) feels very wrong. Also, it doesn't work for me when using e.g. community.docker.docker_network
applied on a remote machine.
ANSIBLE_COLLECTIONS_PATHS=~/.local/share/virtualenvs/ansible-onxPID3p/lib/python3.9/site-packages/ansible_collections ansible-playbook ...
still gives me the ModuleNotFoundError: No module named 'ansible_collections'
The full traceback is:
Traceback (most recent call last):
File "/root/.ansible/tmp/ansible_mitogen_runner_fxo0eidb/docker_network.py", line 285, in <module>
from ansible_collections.community.general.plugins.module_utils.docker.common import (
ModuleNotFoundError: No module named 'ansible_collections'
fatal: [myhost]: FAILED! => changed=false
module_stderr: ''
module_stdout: |-
Traceback (most recent call last):
File "/root/.ansible/tmp/ansible_mitogen_runner_fxo0eidb/docker_network.py", line 285, in <module>
from ansible_collections.community.general.plugins.module_utils.docker.common import (
ModuleNotFoundError: No module named 'ansible_collections'
msg: |-
MODULE FAILURE
See stdout/stderr for the exact error
rc: 1
This fails as if ansible_collections
should be installed on the target machine, but this should not be the case (successful without Mitogen).
ansible-galaxy collection list
lists the collection just fine too:
$ ansible-galaxy collection list
# /home/gert/.local/share/virtualenvs/ansible-onxPID3p/lib/python3.9/site-packages/ansible_collections
Collection Version
------------------------- -------
[...]
community.docker 1.2.2
[...]
community.general 1.3.6
[...]
Update: I managed to solve this issue by upgrading the ansible
package to 3.3.0
(with ansible-base
being 2.10.8
). 🎉
Any updates?
Which version of Ansible are you running? ansible 2.10.3 config file = ansible.cfg configured module search path = ['/Users/ccravens/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /usr/local/Cellar/ansible/2.10.4/libexec/lib/python3.9/site-packages/ansible executable location = /usr/local/bin/ansible python version = 3.9.1 (default, Dec 10 2020, 10:36:41) [Clang 11.0.0 (clang-1100.0.33.17)]
Is your version of Ansible patched in any way? No... Not that I know of. I did install the route53 with galaxy:
ansible-galaxy collection install community.aws
https://docs.ansible.com/ansible/latest/collections/community/aws/route53_module.htmlAre you running with any custom modules, or
module_utils
loaded? NoHave you tried the latest master version from Git? Yes, both
master
andv0.3.0-rc.0
Do you have some idea of what the underlying problem may be? None, but I think it may be due to Ansible 2.10
Mention your host and target OS and versions Mac OSX - running
local
Mention your host and target Python versions Same as above, running
local
If reporting a crash or hang in Ansible, please rerun with -vvv and include
If reporting any kind of problem with Ansible, please include the Ansible version along with output of "ansible-config dump --only-changed"