Parallelization for with_ loops

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}}”

no, loops are serialized