Currently something like the following:
- <some action>
run_once: true
when: item == true
with_random_choice:
- true
- false
Will run only once even when the task is skipped (item = false
).
There are cases when it is desired to run a task until it was run successfully for the first time.
What if run_once
offered a bit more options?
run_once: success
: Run until the task is successfully run on a host
run_once: not_skipped
: Run until task was not skipped
Or an additional task keyword (which sounds even better):
run_until: <Any statement may be used that can also be used in when>
That would allow great freedom in deciding until when a task is run.
It also separates well from the until
task keyword which is used with retries
.
Git issues about the current limitation:
https://github.com/ansible/ansible/issues/23594
https://github.com/ansible/ansible/issues/11496
https://github.com/ansible/ansible/issues/18821
https://github.com/ansible/ansible/issues/13226
Threads:
https://groups.google.com/forum/#!topic/ansible-project/CNTYdNHaWqM
https://groups.google.com/forum/#!topic/ansible-project/0YIQktue6uA
What do you think?