-
Notifications
You must be signed in to change notification settings - Fork 666
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
Conversation
Label error. Requires exactly 1 of: bug, enhancement, major, minor, patch, skip-changelog. Found: |
So I was curious why $ MOLECULE_GLOB="./extensions/molecule/*/molecule.yml" molecule test
$ MOLECULE_GLOB="$(pwd)/extensions/molecule/*/molecule.yml" molecule test
|
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.
This update:
molecule test
MOLECULE_GLOB="**/molecule/*/molecule.yml"
This allows:
.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 settingMOLECULE_GLOB="**/molecule/*/molecule.yml"
will globber clobber and delete the collection folder. This occurs in the presence of agalaxy.yml
- as molecule callsansible_compat.runtime(isolate=False)
and will runansible_compat.runtime.prepare_environment
. However, if you delete thegalaxy.yml
OR chdir intoCOLLECTION_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.eCOLLECTION_NAME/extensions/molecule/SCENARIO_NAME/molecule.yml
. As it callsbase.get_configs
and sets the argumentglob=str"**/molecule/*/molecule.yml"
.This does not occur with
molecule test
, as it calls tobase.execute_cmdline_scenarios
and usesMOLECULE_GLOB = os.environ.get("MOLECULE_GLOB", "molecule/*/molecule.yml")
.Attempting to set an env var
MOLECULE_GLOB="**/molecule/*/molecule.yml"
will fail, astest
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: