Parallelization for with_ loops

16 views
Skip to first unread message

P S

unread,
May 27, 2019, 5:06:16 AM5/27/19
to Ansible Project
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}}" 



Brian Coca

unread,
May 29, 2019, 9:21:05 AM5/29/19
to Ansible Project
no, loops are serialized


--
----------
Brian Coca
Reply all
Reply to author
Forward
0 new messages