# How to run Ansible tasks in parallel

**URL:** <https://forum.ansible.com/t/how-to-run-ansible-tasks-in-parallel/34241>\
**Category:** Ansible Project\
**Created:** [November 25, 2020, 5:56pm UTC](https://forum.ansible.com/t/how-to-run-ansible-tasks-in-parallel/34241 "2020-11-25T17:56:57Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Prathap\_Dasari](https://avatars.discourse-cdn.com/v4/letter/p/db5fbb/32.png) [@Prathap\_Dasari](https://forum.ansible.com/u/Prathap_Dasari)\
**Post date:** [November 25, 2020, 5:56pm UTC](https://forum.ansible.com/t/how-to-run-ansible-tasks-in-parallel/34241/1 "2020-11-25T17:56:57Z")

</div>

Hi Team ,

Is it possible to run Ansible tasks in parallel ? If yes , Kindly let me know How?

Regards,  
Prathap

---

<div class="post-metadata">

**Author:** ![Kundan\_Singh](https://avatars.discourse-cdn.com/v4/letter/k/958977/32.png) [@Kundan\_Singh](https://forum.ansible.com/u/Kundan_Singh)\
**Post date:** [November 25, 2020, 6:01pm UTC](https://forum.ansible.com/t/how-to-run-ansible-tasks-in-parallel/34241/2 "2020-11-25T18:01:01Z")

</div>

By default ansible run tasks parallel .but if you feel latency from one host you can use.

Strategy: free

In your play and execute it parallel

Hope that clears your doubts

Regards  
Kundan singh

---

<div class="post-metadata">

**Author:** ![Prathap\_Dasari](https://avatars.discourse-cdn.com/v4/letter/p/db5fbb/32.png) [@Prathap\_Dasari](https://forum.ansible.com/u/Prathap_Dasari)\
**Post date:** [November 25, 2020, 6:06pm UTC](https://forum.ansible.com/t/how-to-run-ansible-tasks-in-parallel/34241/3 "2020-11-25T18:06:41Z")

</div>

Ok . That was not my question … apologies for that …

I would like to run playbooks parallel . is it possible ?

Regards,  
Prathap

---

<div class="post-metadata">

**Author:** ![vbotka](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vbotka/32/359_2.png) [@vbotka](https://forum.ansible.com/u/vbotka)\
**Post date:** [November 25, 2020, 6:56pm UTC](https://forum.ansible.com/t/how-to-run-ansible-tasks-in-parallel/34241/4 "2020-11-25T18:56:06Z")

</div>

No. It's not possible. The utility "ansible-playbook" is not able to  
run playbooks in parallel. Only serial execution of plays or imported  
playbooks is available. See "import\_playbook"  
[https://docs.ansible.com/ansible/latest/collections/ansible/builtin/import\_playbook\_module.html](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/import_playbook_module.html)

Hypothetical asynchronous task "include\_playbook" is probably what you  
might be looking for. There is no such module and there are no  
options how to create such task. Only tasks can be run in parallel.  
See "Asynchronous actions and polling"  
[https://docs.ansible.com/ansible/latest/user\_guide/playbooks\_async.html](https://docs.ansible.com/ansible/latest/user_guide/playbooks_async.html)

You'll have to start "ansible-playbook" for each playbook you want to  
run in parallel.

---

<div class="post-metadata">

**Author:** ![Prathap\_Dasari](https://avatars.discourse-cdn.com/v4/letter/p/db5fbb/32.png) [@Prathap\_Dasari](https://forum.ansible.com/u/Prathap_Dasari)\
**Post date:** [November 25, 2020, 6:58pm UTC](https://forum.ansible.com/t/how-to-run-ansible-tasks-in-parallel/34241/5 "2020-11-25T18:58:50Z")

</div>

Ok … Thank you for the clarification 👌

---

<div class="post-metadata">

**Author:** ![Mauricio\_Tavares](https://avatars.discourse-cdn.com/v4/letter/m/b5e925/32.png) [@Mauricio\_Tavares](https://forum.ansible.com/u/Mauricio_Tavares)\
**Post date:** [November 25, 2020, 7:21pm UTC](https://forum.ansible.com/t/how-to-run-ansible-tasks-in-parallel/34241/6 "2020-11-25T19:21:31Z")

</div>

> \> I would like to run playbooks parallel . is it possible ?
> 
> No. It's not possible. The utility "ansible-playbook" is not able to  
> run playbooks in parallel. Only serial execution of plays or imported  
> playbooks is available. See "import\_playbook"  
> [https://docs.ansible.com/ansible/latest/collections/ansible/builtin/import\_playbook\_module.html](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/import_playbook_module.html)
> 
> Hypothetical asynchronous task "include\_playbook" is probably what you  
> might be looking for. There is no such module and there are no  
> options how to create such task. Only tasks can be run in parallel.  
> See "Asynchronous actions and polling"  
> [https://docs.ansible.com/ansible/latest/user\_guide/playbooks\_async.html](https://docs.ansible.com/ansible/latest/user_guide/playbooks_async.html)
> 
> You'll have to start "ansible-playbook" for each playbook you want to  
> run in parallel.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;That was exactly what I was going to suggest: start multiple  
"ansible-playbook" instances in parallel.

---

<div class="post-metadata">

**Author:** ![Prathap\_Dasari](https://avatars.discourse-cdn.com/v4/letter/p/db5fbb/32.png) [@Prathap\_Dasari](https://forum.ansible.com/u/Prathap_Dasari)\
**Post date:** [November 25, 2020, 7:41pm UTC](https://forum.ansible.com/t/how-to-run-ansible-tasks-in-parallel/34241/7 "2020-11-25T19:41:32Z")

</div>

Ok . But I have below two yml files.  
There is no dependence between both yml files . Now How can I run them parallel at the same time ? Any advice please ?

i.e :

**patching.yml**

---

<div class="post-metadata">

**Author:** ![racke](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/racke/32/4767_2.png) [@racke](https://forum.ansible.com/u/racke)\
**Post date:** [November 25, 2020, 7:44pm UTC](https://forum.ansible.com/t/how-to-run-ansible-tasks-in-parallel/34241/8 "2020-11-25T19:44:56Z")

</div>

> Ok . But I have below two yml files.  
> There is no dependence between both yml files . Now How can I run them parallel at the same time ? Any advice please ?

Why do you want them to run in parallel? What are these roles are doing?

Regards  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Racke

---

<div class="post-metadata">

**Author:** ![vbotka](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vbotka/32/359_2.png) [@vbotka](https://forum.ansible.com/u/vbotka)\
**Post date:** [November 25, 2020, 8:03pm UTC](https://forum.ansible.com/t/how-to-run-ansible-tasks-in-parallel/34241/9 "2020-11-25T20:03:05Z")

</div>

There is plenty of options. See for example "how to run multiple  
shell scripts in parallel"  
[https://serverfault.com/questions/374131/how-to-run-multiple-shell-scripts-in-parallel](https://serverfault.com/questions/374131/how-to-run-multiple-shell-scripts-in-parallel)

---

<div class="post-metadata">

**Author:** ![Prathap\_Dasari](https://avatars.discourse-cdn.com/v4/letter/p/db5fbb/32.png) [@Prathap\_Dasari](https://forum.ansible.com/u/Prathap_Dasari)\
**Post date:** [November 25, 2020, 8:35pm UTC](https://forum.ansible.com/t/how-to-run-ansible-tasks-in-parallel/34241/10 "2020-11-25T20:35:33Z")

</div>

Hi ,

There is no dependency between below two yaml file and also the patching.yaml and second yaml files will be taking at 20 mins to complete task ,hence I am planning to run both yaml file at the same, to reduce the time if it´s possible.

Regards,  
Prathap
