# Ansible parallel block execution

**URL:** <https://forum.ansible.com/t/ansible-parallel-block-execution/29448>\
**Category:** Ansible Project\
**Created:** [January 16, 2019, 9:26am UTC](https://forum.ansible.com/t/ansible-parallel-block-execution/29448 "2019-01-16T09:26:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Raoul](https://avatars.discourse-cdn.com/v4/letter/r/2acd7d/32.png) [@Raoul](https://forum.ansible.com/u/Raoul)\
**Post date:** [January 16, 2019, 9:26am UTC](https://forum.ansible.com/t/ansible-parallel-block-execution/29448/1 "2019-01-16T09:26:37Z")

</div>

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:

```auto
- 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

---

<div class="post-metadata">

**Author:** ![S\_C\_Rigler](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@S\_C\_Rigler](https://forum.ansible.com/u/S_C_Rigler)\
**Post date:** [January 16, 2019, 12:56pm UTC](https://forum.ansible.com/t/ansible-parallel-block-execution/29448/2 "2019-01-16T12:56:44Z")

</div>

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

--Steve

---

<div class="post-metadata">

**Author:** ![Raoul](https://avatars.discourse-cdn.com/v4/letter/r/2acd7d/32.png) [@Raoul](https://forum.ansible.com/u/Raoul)\
**Post date:** [January 16, 2019, 1:46pm UTC](https://forum.ansible.com/t/ansible-parallel-block-execution/29448/3 "2019-01-16T13:46:32Z")

</div>

Hi Steve,

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

Kind regards,  
Raoul

---

<div class="post-metadata">

**Author:** ![Tchia04](https://avatars.discourse-cdn.com/v4/letter/t/fbc32d/32.png) [@Tchia04](https://forum.ansible.com/u/Tchia04)\
**Post date:** [January 17, 2019, 4:39am UTC](https://forum.ansible.com/t/ansible-parallel-block-execution/29448/4 "2019-01-17T04:39:26Z")

</div>

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