Ansible parallel block execution

Hi,

I am using in an Ansible playbook blocks to execute reboots on hosts when required after applying updates. I have to ensure that the hosts are back online after reboot.
Using ‘strategy: free’ so that all defined tasks aren’t executed in linear order and it is not waited for a task to finish, but it looks like the wait_for_connection inside the block definition is blocking the whole playbook until ended.

My current block looks like this:

- when: reboot_required.rc != 0
  block:
  - name: Rebooting host
    become: true
    shell: 'shutdown -r +1 "Reboot required by Server Updates"'
    ignore_errors: true

  - name: wait for server to come back
    wait_for_connection:
      delay: 90
      timeout: 800
    register: reboot_result

  - debug: var=reboot_result

How can I execute more reboots or wait_for_connection in parallel?

Thanks for any hints,
Raoul

There is now a "reboot" module (showed up in 2.7?) that will reboot
the host and wait for it to come back.

--Steve

Hi Steve,

thanks for the hint, I’ll give this module a try.

Kind regards,
Raoul

You can try adding —fork some-large-number to your ansible playbook command to force it execute in parallel