Support tasks tagged molecule-idempotence-nofail, similar to molecule-idempotence-notest
See original GitHub issueProposal: <proposal name>
Author: Nik Reiman <@nre-ableton> IRC: N/A
Date: 2020/07/28
- Status: New
- Proposal type: Enhancement
- Estimated time to implement: Unknown
Motivation
I would like to use Molecule to test roles which have tasks that are not idempotent, but also not have the idempotency task fail or be required to mark such tasks with the changed_when: false
attribute.
A bit more background – I have some Ansible roles which install and configure rather complex services (in this case, Jenkins and Jenkins build nodes via Swarm Client). Before these roles can be safely run, these services must be stopped. Then, several tasks are run to configure the host, and then the service is restarted. It is impossible (or rather, extremely difficult and/or very impractical) to determine idempotency before shutting down the service, and therefore the most practical way to proceed is to stop the service, run the tasks, and then start it up again at the end of the role.
Ideally, I want molecule to alert me when the intermediate tasks are non-idempotent. Therefore, disabling the idempotency check entirely is not a desirable solution. Also, I need molecule to actually run the service tasks, so molecule-idempotence-notest
will not work since this skips them altogether. Ideally, I wish I could tag such tasks with a tag named something like molecule-idempotence-nofail
. Such tasks should be run by molecule, but the idempotency check will not fail if molecule sees that they have changed the system state.
I’m not sure how difficult or practical this will be to implement, since I’ve not looked into the molecule codebase at all. If this feature is not desired by the community or would be very hard to implement , I’ll close this issue. If it is easy to moderately hard to implement, then I’ll take a look at the code and see if I can come up with a PR.
Problems
What problems exist that this proposal will solve?
- Allowing tasks which are known to change system state to be run, and not fail idempotency tests
Solution proposal
Unknown
Dependencies (optional)
N/A
Testing (optional)
I’m assuming that test cases would be fairly trivial to implement for such a feature.
Documentation (optional)
Ideally this should be documented alongside molecule-idempotence-notest
here.
Anything else?
I’m relatively new to molecule and haven’t contributed before. Apologies for my n00b-ness. 😅
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Interesting. Found this issue, thought “oh
molecule-idempotence-notest
will solve it”, then found it skips the tasks entirely! My usecase - which can’t be that uncommon? - is that I’m creating a tempfile and doing stuff with it. So that isn’t idempotent as the tempfile is different everytime (and it needs to be unique, in this case, so I don’t want to hard-code it) but I want molecule to not fail! Use ofchanged_when
is maybe philosophical but it doesn’t seem right to have ansible mark this as no-change in the real environment just because of a testing limitation.Oh this is a feature I would love to have. I’ve toyed with the idea of adding a flag to the molecule.yml to just completely skip idempotence checking altogether. I’ve settled on just adding “changed_when: false” to tasks that trigger problems, but sometimes that’s just not appropriate. Most common times I have this issue is with calls to tempfile. Sometimes command/shell as well, depending on what they’re doing.