# Do-until loop with an include task

**URL:** <https://forum.ansible.com/t/do-until-loop-with-an-include-task/17609>\
**Category:** Ansible Project\
**Created:** [February 24, 2015, 6:21pm UTC](https://forum.ansible.com/t/do-until-loop-with-an-include-task/17609 "2015-02-24T18:21:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cselden](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/cselden/32/4405_2.png) [@cselden](https://forum.ansible.com/u/cselden)\
**Post date:** [February 24, 2015, 6:21pm UTC](https://forum.ansible.com/t/do-until-loop-with-an-include-task/17609/1 "2015-02-24T18:21:28Z")

</div>

Community,

I’m trying to loop through a tasks script until a task check does not fail. This is what I’d like to use:

- name: Retry startup  
include: retry.yml  
when: check|failed  
retries: 3  
until: not check|failed

The retry.yml script registers ‘check’ again to verify that the startup is successful. However, upon execution, only the first task in the retry.yml script gets run, the rest of the tasks are skipped entirely. Is this a bug/deficiency of the “include” module? I’d like the whole script to be retried instead of the first task. The method below functions, and does what I want but is not as clean.

- name: Retry startup  
include: retry.yml  
when: check|failed

- name: Retry startup  
include: retry.yml  
when: check|failed

- name: Retry startup  
include: retry.yml  
when: check|failed

I know that ansible does not allow inlcude tasks to use ‘with\_items’ or any sort of looping, I assume this is related.

Thanks,  
Chip

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [February 25, 2015, 1:26pm UTC](https://forum.ansible.com/t/do-until-loop-with-an-include-task/17609/2 "2015-02-25T13:26:51Z")

</div>

Yes, this won’t work. Include is not a module, more like a preprocessing macro.
