# Parallelization for with\_ loops

**URL:** <https://forum.ansible.com/t/parallelization-for-with-loops/30426>\
**Category:** Ansible Project\
**Created:** [May 27, 2019, 9:06am UTC](https://forum.ansible.com/t/parallelization-for-with-loops/30426 "2019-05-27T09:06:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![P\_S](https://avatars.discourse-cdn.com/v4/letter/p/3da27b/32.png) [@P\_S](https://forum.ansible.com/u/P_S)\
**Post date:** [May 27, 2019, 9:06am UTC](https://forum.ansible.com/t/parallelization-for-with-loops/30426/1 "2019-05-27T09:06:16Z")

</div>

Hello everyone,

I am using delegate\_to in combination with nested loop in order to create a custom distribution system between a group of hosts.  
The problem is that the nested loop is running sequentially, meaning that it has firstly to finish the task in the first host before proceeding with the second one and so on.  
That results to time consuming tasks like restoring form backup.  
I was wondering if there is a way of running the loops in parallel (with\_items, with\_nested).  
Below i am giving an example on how my task works:

- name: Restore from backup

synchronize:  
src: xxxx  
dest: xxxx  
delegate\_to: “{{hosts[( ((item[0] -1) + (item[1] | int)) - 1) % (hosts|length|int) ] }}”  
run\_once: yes  
with\_nested:

- “{{item0}}”
- “{{item1}}”

---

<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:** [May 29, 2019, 1:20pm UTC](https://forum.ansible.com/t/parallelization-for-with-loops/30426/2 "2019-05-29T13:20:37Z")

</div>

no, loops are serialized
