delegate_to a whole group: is it sequential or parallel?

  • name: disable instance on HAproxy and wait for it to go offline
    haproxy: state=disabled backend=app_back host={{ inventory_hostname_short }} socket=/run/haproxy/admin.sock shutdown_sessions=no wait=yes
    delegate_to: “{{ item }}”
    with_items: groups.haproxy_app

The haproxy_app group has 3 instances (hap01 … hap03), and the main playbook is executed on 10 instances, and it’s sequential, app01 to app10.

Let’s say the main playbook is now executed on app01, and it hits the haproxy task. Is the haproxy task going to be delegated to all haproxy instances at once, in parallel (from the p.o.v. of app01), or is it going to be executed sequentially, hap01, then hap02, then hap03?

Again, I am talking from the p.o.v. of each app instance where the main playbook is being executed.

The reason why I’m asking: This is the task which disables an app instance in HAproxy, and I would like each app to be disabled more or less at once on all proxies (in parallel). I want to avoid, as much as possible, the slower sequential process where an app instance is disabled on each proxy sequentially, one by one.

delegate_to is not inherently parallel or serial, there is no relationships with it and forks. Parallelism depends on the play and task, with_ loops are currently ONLY serial, so if you delegate_to: “{{item}}” it is serial in the loop, but it is parallel across the play hosts.

Makes sense, thanks. But is there a way to parallelize delegate_to somehow? All looping methods I’m aware of are based on with_ and that’s, as you said, serial.