I\'m trying to reboot server running CentOS 7 on VirtualBox. I use this task:
- name: Restart server
command: /sbin/reboot
async: 0
poll:
At reboot time all ssh connections are closed. That's why the Ansible task fails. The ignore_errors: true or failed_when: false additions are no longer working as of Ansible 1.9.x because handling of ssh connections has changed and a closed connection now is a fatal error which can not be caught during play.
The only way I figured out how to do it is to run a local shell task which then starts a separate ssh connection, which then may fail.
- name: Rebooting
delegate_to: localhost
shell: ssh -S "none" {{ inventory_hostname }} sudo /usr/sbin/reboot"
failed_when: false
changed_when: true