You say it's working but do you continue playbook execution after the restart?
I'm also trying to use a task to restart my servers but I would like to wait_for them to come back and continue executing other tasks.
I've tried all variations of the above task (changing async, poll, ignore_errors, switch command/shell modules, etc) but I always get the following error:
fatal: [server] => SSH Error: Shared connection to 1.2.3.4 closed.
It is sometimes useful to re-run the command using -vvvv, which prints SSH debug output to help diagnose the issue.
It seems that the connection is closed too fast and Ansible doesn't understand what is happening.
Can anyone confirm this is the right way to reboot a server and continue playbook execution in Ansible 1.9.0.1?
- name: Restart server
shell: "shutdown -r now