I\'m trying to reboot server running CentOS 7
on VirtualBox. I use this task:
- name: Restart server
command: /sbin/reboot
async: 0
poll:
I am using Ansible 2.5.3. Below code works with ease,
- name: Rebooting host
shell: 'shutdown -r +1 "Reboot triggered by Ansible"'
- wait_for_connection:
delay: 90
timeout: 300
You can reboot immediately, then insert a delay if your machine takes a while to go down:
- name: Rebooting host
shell: 'shutdown -r now "Reboot triggered by Ansible"'
async: 1
poll: 1
ignore_errors: true
# Wait 120 seconds to make sure the machine won't connect immediately in the next section.
- name: Delay for the host to go down
local_action: shell /bin/sleep 120
Then poll to make the playbook return as soon as possible:
- name: Wait for the server to finish rebooting
wait_for_connection:
delay: 15
sleep: 15
timeout: 300
This will make the playbook return as soon as possible after the reboot.