# retries/loop for a bunch of tasks

**URL:** <https://forum.ansible.com/t/retries-loop-for-a-bunch-of-tasks/38738>\
**Category:** Ansible Project\
**Created:** [April 3, 2024, 12:36pm UTC](https://forum.ansible.com/t/retries-loop-for-a-bunch-of-tasks/38738 "2024-04-03T12:36:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Azadeh\_Amirhosseini](https://avatars.discourse-cdn.com/v4/letter/a/46a35a/32.png) [@Azadeh\_Amirhosseini](https://forum.ansible.com/u/Azadeh_Amirhosseini)\
**Post date:** [April 3, 2024, 12:36pm UTC](https://forum.ansible.com/t/retries-loop-for-a-bunch-of-tasks/38738/1 "2024-04-03T12:36:54Z")

</div>

Hi All,

how can I implement ‘retries:’ for a bunch of tasks. Unfortunately it does not work with ‘block:’ and i get the error: ‘ERROR! ‘until’ is not a valid attribute for a block’. Any idea or trick to get the result is highly welocomed.

tasks:

- name: “execute show commands before Update”  
nxos\_command:  
commands: “{{ item }}”  
ignore\_errors: true  
with\_items: “{{ todo }}”  
register: before\_install

- set\_fact:  
out\_before: “{{ out\_before + [item.item] + item.stdout }}”  
with\_items: “{{ before\_install.results }}”

# more tasks come here to do the Software Update…

- name: “Check Output after update”  
block:

- name: “execute show commands after Update”  
nxos\_command:  
commands: “{{ item }}”  
ignore\_errors: true  
with\_items: “{{ todo2 }}”  
register: after\_install

- set\_fact:  
error\_data: “{{ ‘false’ if before\_install == after\_install else ‘true’}}”

retries: 3  
delay: 300  
until: error\_data == ‘false’

---

<div class="post-metadata">

**Author:** ![dnmvisser](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@dnmvisser](https://forum.ansible.com/u/dnmvisser)\
**Post date:** [April 3, 2024, 1:20pm UTC](https://forum.ansible.com/t/retries-loop-for-a-bunch-of-tasks/38738/2 "2024-04-03T13:20:42Z")

</div>

You could put the tasks from the block in a separate file, and then  
include that with include\_tasks.  
That does allow you to loop over it.
