molecule icon indicating copy to clipboard operation
molecule copied to clipboard

Molecule reads collections_path and ignores collection_paths in ansible.cfg

Open amarao opened this issue 3 years ago • 3 comments

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:

  1. Create new project
  2. Configure ansible.cfg:
    [defaults]
    collection_path = collection
    
  3. Run molecule --debug create
  4. Observe value for ANSIBLE_COLLECTIONS_PATH. It includes the current_project_directory/collections.
  5. Change ansible.cfg:
    [defaults]
    collection_paths = collection
    
  6. Run molecule reset
  7. run moecule --debug create
  8. Observe value for ANSIBLE_COLLECTIONS_PATH.

It does not include current_project_directory/collections.

amarao avatar Jul 27 '22 09:07 amarao

@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?

zhan9san avatar Jul 28 '22 04:07 zhan9san

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.

nre-ableton avatar Sep 08 '22 10:09 nre-ableton

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.

amarao avatar Sep 08 '22 14:09 amarao