After running a reboot on the machine from the inventory, the ssh connection was lost (as expected) and the playbook came to an end.
---
- name: reboot
hosts: all
become: yes
#strategy: host_pinned
serial: 1
max_fail_percentage: 0
tasks:
- name: restart one by one
shell: ‘reboot --force’
async: 100
poll: 0
register: long_task
I want the playbook to continue to make sure the machine starts up and responds well.
It looks like there is no way to use ‘async_status’ directly because the machine is not available during the restart and I need to come up with:
- a task that consumes some time like ‘sleep’ on the local machine, for example thanks to ‘delegate_to: localhost’ – which does not appear to be a professional approach
- use some built-in Ansible schema to pause the script for a certain amount of time
Then, after a period of time, try to connect to the machine, check the status using the ‘async_status’ module or some specific to check its full functionality.
Questions then arise:
- Is my thinking correct – in relation to the above?
- Do we have other methods to go through the reboot more professionally – perhaps via some native module(s) – suitable for the task at hand?
- what the various strategies for achieving this might be – as far as possible to be applied in practice