Molecule reads collections_path and ignores collection_paths in ansible.cfg
Issue Type
- Bug report
Molecule and Ansible details
molecule 4.0.1 using python 3.10
ansible:2.12.6
delegated:4.0.1 from molecule
Molecule installation method (one of):
- pip
Ansible installation method (one of):
- pip
Detail any linters or test runners used:
Molecule set ANSIBLE_COLLECTIONS_PATH env variable based on collections_path variable in ansible.cfg, whilst ansible has migrated to collections_paths ("s" at the end of paths).
I believe, molecule should respect modern (5.12/5.13 versions of ansible-core) setting.
Steps to reproduce:
- Create new project
- Configure ansible.cfg:
[defaults] collection_path = collection - Run molecule --debug create
- Observe value for
ANSIBLE_COLLECTIONS_PATH. It includes the current_project_directory/collections. - Change ansible.cfg:
[defaults] collection_paths = collection - Run molecule reset
- run moecule --debug create
- Observe value for
ANSIBLE_COLLECTIONS_PATH.
It does not include current_project_directory/collections.
@amarao
Thanks for reporting this.
There are multiple ANSIBLE_COLLECTIONS_PATH in the output of moecule --debug create.
Here is what I tested.
molecule init role -d docker acme.my_new_role
cd my_new_role
cat <<EOF > ~/.ansible.cfg
[defaults]
collection_path = collection
EOF
molecule --debug create
Could you provide the specific actual behavior and expected behavior when we use collection_paths?
I am having similar troubles with molecule. We want to use a custom value for ANSIBLE_COLLECTIONS_PATH, but molecule doesn't respect this env var at all.
As far as I got from code, custom collections are ignored at create stage, but work at converge. But you need to update molecule.yml section for corresponding ansible.cfg options.