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

Fix: Update default globbing pattern for collection matching #4177

Closed
wants to merge 2 commits into from

Commits on May 15, 2024

  1. Fix: Update default globbing pattern for collection matching

    This update:
    - restricts the glob matching for `molecule test`
    - updates the default value for `MOLECULE_GLOB="**/molecule/*/molecule.yml"`
    
    This allows:
    - users to call molecule from the collection folder and molecule will use the
    collection name in the ephemeral cache, `.cache/molecule/COLLECTION_NAME`.
    
    WARNING:
    If working within the ANSIBLE_COLLECTIONS_PATH directory, e.g.
    `~/.ansible/collections/ansible_collections/COLLECTION_NAME` (default), using
    the new default setting `MOLECULE_GLOB="**/molecule/*/molecule.yml"` will
    globber clobber and delete the collection folder. This occurs in the presence of
    a `galaxy.yml` - as molecule calls `ansible_compat.runtime(isolate=False)` and
    will run `ansible_compat.runtime.prepare_environment`. However, if you delete
    the `galaxy.yml` OR chdir into `COLLECTION_NAME/extensions` and it will not
    delete the collection folder.
    
    Currently (v24.2.1):
    Calling `molecule list` will find all molecule.yml files within a collection
    folder that use a nested dir structure, i.e
    `COLLECTION_NAME/extensions/molecule/SCENARIO_NAME/molecule.yml`. As it calls
    `base.get_configs` and sets the argument `glob=str"**/molecule/*/molecule.yml"`.
    
    This does not occur with `molecule test`, as it calls to
    `base.execute_cmdline_scenarios` and uses
    `MOLECULE_GLOB = os.environ.get("MOLECULE_GLOB", "molecule/*/molecule.yml")`.
    
    Attempting to set an env var MOLECULE_GLOB="**/molecule/*/molecule.yml" will
    fail, as `test` attempts to insert the scenario name into every wild-card. But,
    this fuzzy matching acts as a safe guard against deleting the collection when
    working within the same ANSIBLE_COLLECTIONS_PATH directory:
    	$ MOLECULE_GLOB="**/molecule/*/molecule.yml" molecule test
    	CRITICAL 'defaultdefault/molecule/default/molecule.yml' glob failed.
    trfore committed May 15, 2024
    Configuration menu
    Copy the full SHA
    78b4783 View commit details
    Browse the repository at this point in the history
  2. CI: Update PYTEST_REQPASS

    trfore committed May 15, 2024
    Configuration menu
    Copy the full SHA
    2ee3123 View commit details
    Browse the repository at this point in the history