molecule
molecule copied to clipboard
Additional `--destroy` strategies.
Issue Type
- Feature request
Molecule and Ansible details
ansible 2.8.7
config file = /etc/ansible/ansible.cfg
configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python3.5/dist-packages/ansible
executable location = /usr/local/bin/ansible
python version = 3.5.2 (default, Oct 8 2019, 13:06:37) [GCC 5.4.0 20160609]
molecule, version 2.22
Molecule installation method (one of):
-
pip Ansible installation method (one of):
-
pip
Desired Behavior
I Would like to request/suggest new Strategies for the --destroy option in the test command.
In my development work-flow I usually want to inspect the Machines created by molecule, when a Failure in i.E. in the Converge Step occurred.
Having a on-failure, on-success or an interactive ask strategy would allow to accommodate for different work-flows.
The on-failure strategy would destroy the machines, if any of the previous steps failed,
the on-success strategy would destroy the machines upon successfully running all Steps.
the ask strategy would interactively ask for the desired action, upon failure.
If this feature/request is considered useful, I am willing to try and take on this Issue myself.
To me on-failure would seem to be the most useful default as well - at the moment when test fails you have to either add --destroy=never or go through the steps manually.
I would't change the default because that would break expectations in CI workflows (always tear it down). I do sympathise with the development workflow though and this is definitely an issue for beginners ("Where is the box gone? Oh what? I need to run it all over again!?"). One thought is to use the proposed ask strategy as default when we detect a tty (dev mode) but otherwise, destroy all. However, introducing an interactive prompt feels a bit meh... maybe we can at least introduce schema configuration options for new strategies as a first step? AFAIR, there is just --destroy=never on the CLI and nothing else?
Yeah fair enough re breaking CI! CLI currently only has =never and =always (see #3009). Personally I'd be fine with no autodetection that we're in a "dev mode" and I'd just learn to put --destroy=on-failure or on-error or whatever it is on the CLI. If it could get set via an environment var I guess that might help.
Then maybe keep =never to preserve existing expectations and add on-failure/on-success strategy options, also configurable by env and please send a bit of docs love with the change and I'll be sure to give it a review. That's my take on this anyway.