# more freedom and options for \`run\_once\`

**URL:** <https://forum.ansible.com/t/more-freedom-and-options-for-run-once/30037>\
**Category:** Ansible Project\
**Created:** [April 2, 2019, 11:47am UTC](https://forum.ansible.com/t/more-freedom-and-options-for-run-once/30037 "2019-04-02T11:47:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Uffi\_Schnuffi1](https://avatars.discourse-cdn.com/v4/letter/u/e47774/32.png) [@Uffi\_Schnuffi1](https://forum.ansible.com/u/Uffi_Schnuffi1)\
**Post date:** [April 2, 2019, 11:47am UTC](https://forum.ansible.com/t/more-freedom-and-options-for-run-once/30037/1 "2019-04-02T11:47:25Z")

</div>

Currently something like the following:

```auto

- <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/23594)  
[https://github.com/ansible/ansible/issues/11496](https://github.com/ansible/ansible/issues/11496)

[https://github.com/ansible/ansible/issues/18821](https://github.com/ansible/ansible/issues/18821)  
[https://github.com/ansible/ansible/issues/13226](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/CNTYdNHaWqM)  
[https://groups.google.com/forum/#!topic/ansible-project/0YIQktue6uA](https://groups.google.com/forum/#!topic/ansible-project/0YIQktue6uA)

What do you think?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [April 3, 2019, 7:52pm UTC](https://forum.ansible.com/t/more-freedom-and-options-for-run-once/30037/2 "2019-04-03T19:52:19Z")

</div>

I've really regretted the naming of this feature, its really  
`run_on_first_active_host_in_play_execution_apply_facts_and_register_to_all`  
, I don't think we can change the current nature of run\_once from  
boolean to string choices, but I am in favor of a new option that does  
a better job of specifying conditions.
