Skip to content

Silent drop of scenarios whose molecule.yml match a .gitignore rule #4697

Description

@nipil

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

$  pip install --force-reinstall "git+https://github.com/ansible-community/molecule-plugins.git@main"
$  pip install --force-reinstall "molecule-plugins[podman] @ git+https://github.com/ansible-community/molecule-plugins.git@main"
$ molecule --version
molecule 26.8.0 using python 3.13
    ansible:2.21.4
    podman:26.7.16.dev4 from molecule_plugins requiring collections: containers.podman>=1.8.1
    azure:26.7.16.dev4 from molecule_plugins
    default:26.8.0 from molecule
    openstack:26.7.16.dev4 from molecule_plugins requiring collections: openstack.cloud>=2.1.0
    ec2:26.7.16.dev4 from molecule_plugins
    gce:26.7.16.dev4 from molecule_plugins requiring collections: google.cloud>=1.0.2 community.crypto>=1.8.0
    containers:26.7.16.dev4 from molecule_plugins requiring collections: ansible.posix>=1.4.0 community.docker>=3.10.2 containers.podman>=1.8.1
    docker:26.7.16.dev4 from molecule_plugins requiring collections: community.docker>=3.10.2 ansible.posix>=1.4.0
    vagrant:26.7.16.dev4 from molecule_plugins

What happened

Molecule test fails with CRITICAL 'molecule/default/molecule.yml' glob failed. Exiting even when running from within a valid role directory, and even though the file exists and both std lib glob can correctly return it.

Root cause seems to be get_configs -> filter_ignored_scenarios -> git check-ignore : as a result drops any matched path that git reports as ignored, because the folder the role is in is indeed ignored, even if it is the scenario i am actually trying to locally test

The error is not helpful because "glob failed" does not actually lead the real cause, which is a git ignore match : by removing the ignore rule, it instantly works again

Suggestion: at a minimum, emit a distinct/clearer error message when scenarios are excluded specifically due to git check-ignore, not "nothing found", or let it run by not taking git ignore into account (i am new to molecule, i do not know if it is a good idea outside of my own use)

Thanks in advance

Reproducing example

How to reproduce

- a role directory matching a git ignore pattern (vendored/Galaxy roles) containing a valid molecule/default/molecule.yml, with the role itself untracked by git = molecule test from inside that role directory fails.

- removing the ignore pattern, or force-adding the role path to git (not a solution for a galaxy role, just for testing) : works again


$ pwd
~/git/my_project/ansible/roles/my_role

$ cat ../../.gitignore
roles/

$ molecule test
CRITICAL 'molecule/default/molecule.yml' glob failed.  Exiting.
ERROR    'molecule/default/molecule.yml' glob failed.  Exiting.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions