Is it possible to run subset of Ansible Molecule scenarios based on some criteria

204 views Asked by At

If I have a molecule directory with multiple scenarios is it possible to run a subset of the scenarios based on some criteria that I specify at run time

For example if I have the following 5 scenarios which are somehow categorised:

molecule

  • scenario-1 (categories log-running)
  • scenario-2 (categories os-a)
  • scenario-3 (categories push, os-a)
  • scenario-4 (categories weekend)
  • scenario-5 (categories push)

molecule test --category push

=> run scenario-3 + scenario-5

molecule test --category os-a

=> run scenario-2 + scenario-3

molecule test --category long-running:weekend

=> run scenario-1 + scenario-4

I'm looking for something similar to Ansible tags but on the Molecule scenario level.

1

There are 1 answers

0
George Shuklin On

Molecule does not have this level of scenario management. You can run molecule few times with different parameters based on your criteria (bash glue, I suppose, as usual).

Also, normally, when you have multiple scenarios, you want to run them in parallel (e.g. with power of your CI). Put it into matrix (or whatever this is called, strategy, etc), and add per-scenario condition; should it run it or not under given set of variables/circumstances.