…PPED
Currently, actions may only ever gain STATUS_FIXED, STATUS_SKIPPED or
STATUS_FAILED. This becomes an issue when there's a heavy action which shall
only be executed when necessary and other items depending on that action.
When the action succeeds, everything is fine.
Then the second time, the action is skipped because of an `unless`. And to not
skip all dependent items, `cascade_skip: False` is implied to the action
because of the `unless` attribute.
However, when the action fails, this is treated the same as an `unless`-skip
and since `cascade_skip` is still false, all dependent items don't care and
are executed nonetheless, despite on of their dependencies not being ready.
To solve this, a new `ok_when` attribute is introduced which works kinda like
`unless`, however instead of implying `cascade_skip` and letting the item be
skipped when nothing is to be done, the item just gains STATUS_OK if the
condition/test succeeds.
This is basically the `action` version of an item whose task is already
completed like a `file` which contains already the expected content or a
`svc_systemd` which is already running and enabled.
Same now goes for an `action` which just doesn't need to be run because its task
has already been fulfilled in the past, there is nothing to fix or do and so the
item can just report STATUS_OK.
As described in #987 I see the need for a way to let actions gain STATUS_OK to be able to distinguish between a executed-but-failed and a not-executed-because-nothing-to-do action (or any item in general).
Currently, actions may only ever gain STATUS_FIXED, STATUS_SKIPPED or STATUS_FAILED.
This becomes an issue when there's a heavy action which shall only be executed when necessary and other items depending on that action.
When the action succeeds, everything is fine.
Then the second time, the action is skipped because of an unless. And to not skip all dependent items, cascade_skip: False is implied to the action because of the unless attribute.
However, when the action fails, this is treated the same as an unless-skip and since cascade_skip is still false, all dependent items don't care and are executed nonetheless, despite on of their dependencies not being ready.
To solve this, a new ok_when attribute (the name is kinda lame and inspired by Ansible's naming. Open to better naming proposals) is introduced which works kinda like unless, however instead of implying cascade_skip and letting the item be skipped when nothing is to be done, the item just gains STATUS_OK if the condition/test succeeds.
This is basically the action-version of an item whose task is already completed like a file which contains already the expected content or a svc_systemd which is already running and enabled.
Same now goes for an action which just doesn't need to be run because its task has already been fulfilled in the past, there is nothing to fix or do and so the item can just report STATUS_OK.
I've not yet included documentation in this PR as I wanted to know your stance about this change beforehand.
My take for the documentation would be to recommend this attribute over unless because to me it feels much more intuitive that subsequent/dependent items are skipped when an action fails and I've been biten a couple of times with the current behaviour of unless.