Restart server playbook fails on one set of targets, but not on another.

I have the following playbook snippet

`

Check out https://stackoverflow.com/questions/29955605/how-to-reboot-centos-7-with-ansible

It fails because the server shutdown too fast.
Use
  shell: sleep 2 && reboot
instead of your command: and it will work without issues.

one more thing - I’m doing something similar and I’ve found it necessary to use wait_for: to determine that port 22 actually went down before I wait for it to come up again. I’ve also used wait_for_conection: to wait for it to come all the way back before I proceed.