molecule
molecule copied to clipboard
Molecule config file in {project}/.config/molecule/config.yml not found
Prerequisites
- [X] This was not already reported in the past (duplicate check)
- [X] It does reproduce it with code from main branch (latest unreleased version)
- [X] I include a minimal example for reproducing the bug
- [X] The bug is not trivial, as for those a direct pull-request is preferred
- [X] Running
pip check
does not report any conflicts - [X] I was able to reproduce the issue on a different machine
- [X] The issue is not specific to any driver other than 'default' one
Environment
OS Release: Red Hat 8.9
$molecule --version
molecule 6.0.3 using python 3.11
ansible:2.16.2
azure:23.5.0 from molecule_plugins
containers:23.5.0 from molecule_plugins requiring collections: ansible.posix>=1.3.0 community.docker>=1.9.1 containers.podman>=1.8.1
default:6.0.3 from molecule
docker:23.5.0 from molecule_plugins requiring collections: community.docker>=3.0.2 ansible.posix>=1.4.0
ec2:23.5.0 from molecule_plugins
gce:23.5.0 from molecule_plugins requiring collections: google.cloud>=1.0.2 community.crypto>=1.8.0
podman:23.5.0 from molecule_plugins requiring collections: containers.podman>=1.7.0 ansible.posix>=1.3.0
vagrant:23.5.0 from molecule_plugins
What happened
ISSUE:
Molecule settings put into {PROJECT_DIR}/.config/molecule/config.yml
are not found or used, but they are if I move .config/molecule/.config.yml
to my user home directory.
EXPECTATIONS:
Molecule documentation states that we can put configurations into {PROJECT_DIR}/.config/molecule/config.yml
or into ~/.config/molecule/config.yml
So both options should work.
EXAMPLE: My example directory structure:
$ tree -a my_project/
my_project/
├── .config
│ └── molecule
│ └── config.yml
└── roles
└── somerole
└── molecule
└── default
├── converge.yml
├── create.yml
├── destroy.yml
└── molecule.yml
Here are the contents of config.yml
:
---
driver:
name: docker
Here's what I see if I configure using ~/.config/molecule/config.yml
- it finds the file and the settings are used, this is good:
$ molecule converge
INFO Found config file /home/my_user/.config/molecule/config.yml
When I remove that ~/.config/molecule/config.yml
and only have ./my_project/.config/molecule/config.yml
it does not read these settings. I tried moving the .config directory to all different levels within the project dir with no luck.
POSSIBLE SOLUTION
I believe the issue lies in the find_vcs_root
function in the file util.py
Adding , ".config"
into the dirs variable in the find_vcs_root
function definition line seems to resolve the issue for me:
def find_vcs_root(location="", dirs=(".git", ".hg", ".svn", ".config"), default=None) -> str:
I wanted to submit this as a PR as it seems fairly trivial but I am having issues getting my environment configured correctly. I apologize in advance if I did not contribute this exactly to the guidelines.
Reproducing example
No response
A PR that fixes this would be welcomed.