Check if computers are off before action

Hi all,
I use ansible to shutdown some computer. I need to do it in a certain order.
My point is that I would like to check first if some machines are really off before stopping a second group of computers.

More specifically, I have two pools in my hosts file : computing-servers and storage-servers
I want to shutdown computing server AND BE SURE that they are all off before shutting down the storage-servers.

Any idea how I can do that ?

Thanks for your help.
F.

​How would you check that manually (without ansible)?​
Then we can see how you can implement that check in ansible.

Hi,

Maybe the wait_for module with with_items can help.

Greetings,
gw

​He want to be sure the server is halted, wait_for probably just checks
some service port like ssh, which doesn't say if the machine is powered of.
IMHO he'll need some out of band way to check that.​

Hi Francois,

I am not sure what the hardware is , but if it supports IPMI , probably you can use ipmi commands or write up an IPMI module to do the same

Regards,
Benno

Using bash I would do a function like :

function is_alive {
ping -w 1 $1 >/dev/null
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
return 0
else
return 1
fi
}

and test return for each machine in the pool.

Sure I could use IPMI… for the computers which support it (but unfortunatey not all of them).
And the other point is that all my pools are already defined in ansible, so it would be cool to use them directly from ansible.

ipmi module ++

Finally, I found a way to do it.
I juste run “ansible computing-servers --list-hosts” into a bash script and use the return to ping the machines one by one. Thus when they are all down, I can shutdown the storage-servers.
F.