I didn’t know the answer to this, so I asked Codex to check the molecule source:
The relevant flow is:
get_configs()discoversmolecule.ymlfiles withwcmatch.glob()insrc/molecule/command/base.py:490-529.Scenarios.allthen sorts the resulting scenarios with:scenarios.sort(key=lambda x: x.directory)So with this layout:
molecule/reverse1/molecule.yml molecule/reverse2/molecule.ymlMolecule will process:
reverse1 reverse2The existing test
tests/unit/test_scenarios_ordered.py:30-63confirms this behavior. It supplies configurations in the ordertwo,one,three, but uses directories named01_foo,02_foo, and03_foo. Molecule returns them asone,two,three, based on directory order.
Here is an example with shared_state: true and using uv run tox --ansible -e molecule-py3.12-2.19 - the scenario sequence is that default -> create runs first, then all the scenario specific sequences, then finally default -> destroy:
DETAILS
default ➜ create: Executed: Successful
agent_airgap ➜ prepare: Executed: Successful
agent_airgap ➜ converge: Executed: Successful
agent_airgap ➜ cleanup: Executed: Successful
agent_default ➜ prepare: Executed: Successful
agent_default ➜ converge: Executed: Successful
agent_default ➜ cleanup: Executed: Successful
agent_token ➜ prepare: Executed: Successful
agent_token ➜ converge: Executed: Successful
agent_token ➜ cleanup: Executed: Successful
hub_default ➜ converge: Executed: Successful
hub_default ➜ verify: Executed: Successful
hub_default ➜ cleanup: Executed: Successful
default ➜ destroy: Executed: Successful
SCENARIO RECAP
default : actions=1 successful=1 disabled=0 skipped=0 missing=0 failed=0
agent_airgap : actions=3 successful=3 disabled=0 skipped=0 missing=0 failed=0
agent_default : actions=3 successful=3 disabled=0 skipped=0 missing=0 failed=0
agent_token : actions=3 successful=3 disabled=0 skipped=0 missing=0 failed=0
hub_default : actions=3 successful=3 disabled=0 skipped=0 missing=0 failed=0
default : actions=1 successful=1 disabled=0 skipped=0 missing=0 failed=0
molecule-py3.12-2.19: OK (241.33=setup[0.01]+cmd[4.79,73.05,163.48] seconds)
congratulations :) (241.80 seconds)
I don’t think that is possible with molecule as is today.