-
Notifications
You must be signed in to change notification settings - Fork 664
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
v6 fails due to collection path not aligning with ansible collection path #4015
Comments
I don't know if my issue is similar, but since Molecule 6.0.0, Molecule has been installing roles and collections into the roles and collections top level dirs in my roles and playbooks. It used to install it into ~/.cache/molecule/.... But then the other issue is that when Molecule actually runs the prepare stage, Ansible can't find my role because Ansible is running from the scenario's directory. I also find that adding ansible.cfg in the root of my project doesn't seem to help. This only seems to work when I set
But this also forces me to:
So what's the proper solution here and am I doing this wrong? |
Thanks for reporting this issue. I'll take a look. |
Guessing this is also related to #4017 |
Same issue here, can reproduce locally if I update everything to the latest releases on my Mac:
|
I experience exactly the same issue with Molecule 6.0.1. In the prepare stage, the roles cannot be found because they are installed in the top-level roles directory. |
Note that Updating to latest ansible-compat 4.1.7 did not fix this issue |
@lod and @geerlingguy Could you help verify whether the issue is fixed in ansible-compat 4.1.7? I believe the issue you describe is different. We are still working on it. |
What I noticed today (with ansible-compat 4.1.7) is that when the folder
I have to override it in the molecule.yml file, that roles installed from
If the top-level
|
I seem to have the same issue as @isuftin:
This was working before v6. |
Upgrading from ansible-compat I'm using molecule 6.0.1 and can provide links to the action if anyone needs. |
Thanks @zhan9san working with ansible_compat-4.1.9 |
I think things are working as well on my end. Just updated to ansible-compat 4.1.0..
|
Spoke too soon. It seems we're getting tripped up in the prepare stage. We're running this on a GitLab runner... Here's the interesting bits..
So while it installed my wma.ssl_filtering role to Also note my config.yml for molecule includes: dependency:
name: galaxy
options:
role-file: molecule/common/role_requirements.yml
requirements-file: molecule/common/collections_requirements.yml
force: false The role that can't be found is specified @ molecule/common/role_requirements.yml but NOT in meta/requirements.yml - Thats because it's a test-time only role. And it gets installed into my role's roles/ directory as a sibling to requirements.yml. However geerlingguy.java does not get installed there. That role is specified in meta/requirements.yml. And for scenarios without a prepare step, my role works fine because geerlingguy.java is found no problem. Finally, the only other difference I can think of is that we install geerlingguy.java from ansible galaxy but we pull wma.ssl_filtering from our private gitlab instance. |
Has there been any movement on the roles portion of this? This still seems to be an issue in the latest Molecule install. Still working as expected in |
I still have the same issue indeed:
running molecule<6 still works running from ~/git/ansible/hyperglass
|
I think I found my issue:
This is following the XDG Base directory spec and ansible is listed here: if I add the directory to my env, this fixes it: (notice the $ANSIBLE_HOME at the end)
|
Issue Type
I'm not entirely sure that this is a molecule bug, it may be a ansible-compat bug, I'm not familiar enough with the ecosystem to be certain.
However the failures started with molecule v6.0, so it should be documented here until it is fixed even if the fix is elsewhere.
Molecule and Ansible details
Test environment is an official Debian bookworm-slim container, the following steps were run to create the environment
Actual Behaviour
On running
molecule test
I get an exception, the tail of which isDetails
The collection files are all installed in /usr/local/lib/python3.11/dist-packages/ansible_collections
Ansible galaxy uses the following search paths in execute_list_collection, cli/galaxy.py:1619
The third element, AnsibleCollectionConfig.collection_paths, is set to
['/root/.ansible/collections', '/usr/local/lib/python3.11/dist-packages']
It isn't clear to me how collection_paths gets the dist-packages element, but it is there.
https://docs.ansible.com/ansible/latest/reference_appendices/config.html#collections-paths says that the default doesn't include that path. There is no /etc/ansible/ or ~/.ansible.cfg
molecule uses ansible-compat, ansible-compat follows the documentation not the actual ansible behaviour and only searches
['/root/.ansible/collections', '/usr/share/ansible/collections']
. Which is why it can't find any of my collections.ansible-galaxy collection list
shows all the collectionsansible-galaxy collection install containers.podman community.docker ansible.posix
fails with "Nothing to do. All requested collections are already installed. If you want to reinstall them, consider using
--force
."ansible -c local -i 127.0.0.1, -m containers.podman.podman_image_info all
finds and executes the module (which fails, but it finds and tries it)Workaround
ansible-galaxy collection install --collections-path /usr/share/ansible/collections containers.podman community.docker ansible.posix --force
This installs the specified collections in /usr/share/ansible/collections allowing molecule to run.
(I also tried symlinking but ansible-compat doesn't seem to follow the link)
The text was updated successfully, but these errors were encountered: