Skip to content
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

Molecule config file in {project}/.config/molecule/config.yml not found #4142

Open
7 tasks done
erichoog opened this issue Feb 24, 2024 · 1 comment
Open
7 tasks done
Labels

Comments

@erichoog
Copy link

erichoog commented Feb 24, 2024

Prerequisites

  • This was not already reported in the past (duplicate check)
  • It does reproduce it with code from main branch (latest unreleased version)
  • I include a minimal example for reproducing the bug
  • The bug is not trivial, as for those a direct pull-request is preferred
  • Running pip check does not report any conflicts
  • I was able to reproduce the issue on a different machine
  • 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.ymlit 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

@erichoog erichoog added the new label Feb 24, 2024
erichoog added a commit to erichoog/molecule that referenced this issue Feb 28, 2024
@ssbarnea ssbarnea added bug and removed new labels Feb 28, 2024
@ssbarnea
Copy link
Member

A PR that fixes this would be welcomed.

Qalthos pushed a commit to erichoog/molecule that referenced this issue Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

Successfully merging a pull request may close this issue.

2 participants