# Ansible rolling restart in multi-clustered environment

**URL:** <https://forum.ansible.com/t/ansible-rolling-restart-in-multi-clustered-environment/33177>\
**Category:** Ansible Project\
**Created:** [June 14, 2020, 9:04pm UTC](https://forum.ansible.com/t/ansible-rolling-restart-in-multi-clustered-environment/33177 "2020-06-14T21:04:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rishabh\_Kumar](https://avatars.discourse-cdn.com/v4/letter/r/df788c/32.png) [@Rishabh\_Kumar](https://forum.ansible.com/u/Rishabh_Kumar)\
**Post date:** [June 14, 2020, 9:04pm UTC](https://forum.ansible.com/t/ansible-rolling-restart-in-multi-clustered-environment/33177/1 "2020-06-14T21:04:11Z")

</div>

Hi,

I have a use case where I want to execute rolling updates in multiple clusters. As first step, I have created a task to execute serially on the hosts passed to the task which will execute the restart one node at a time. Currently it takes O(n) time for node restart assuming total number of nodes in all the cluster is n and constant time for node restart. I want to optimise the execution of this ansible job such that the task to restart nodes is executed serially in the cluster but in parallel across the clusters resulting in effective restart time proportional to maximum number of hosts in a cluster. Example for the given inventory -

[Cluster\_1]  
host\_1\_a  
host\_1\_b

[Cluster\_2]  
host\_2\_a  
host\_2\_b

[Cluster\_3]  
host\_3\_a  
host\_3\_b

host\_3\_c

The current execution time is 7\*(reboot\_time) and I want to optimise it to 3\*(reboot\_time). I am not sure if this possible in ansible and would welcome any suggestions. Thanks!
