ansible / molecule

Molecule aids in the development and testing of Ansible content: collections, playbooks and roles
https://ansible.readthedocs.io/projects/molecule/
MIT License
3.89k stars 664 forks source link

RFE: Introduce the `--include` `--exclude` command line parameter for scenario filtering #4003

Open cidrblock opened 1 year ago

cidrblock commented 1 year ago

As a user I want to specify a subset of molecule scenarios to run.

Use cases:

Example:

Assume we have introduced the ability to share state and invetory between scenarios. Assume the default scenario is responsible for provisioning.


# create the infrstructure, shared state, shared inventory and verify it is viable using the default scneario
molecule create
molecule preprare
molecule verify

# run all other scenarios (their destroy is removed from test)
molecule test --exclude default

# destroy the shared infrastructure and invetory
molecule destroy

Long term there may be a way to offer these steps (canned) with a higher level construct above the scenario level at the collleciton level
Qalthos commented 3 months ago

We already have the --all parameter, which sets the scenario name to None which Scenarios interprets as all. An additional filter list could flow through to Scenarios to limit that list beyond allowing a single name.

Qalthos commented 2 months ago

Do we potentially want more nuanced scenario filtering, say as in molecule --include scenario1 --include scenario2 or molecule --all --exclude scenario4 --exclude scenario5?