To reboot a Debian or Ubuntu Linux system using Ansible and wait for it to complete the reboot process, you can use the reboot
module and the wait
command.
Here is an example playbook that reboots a Debian or Ubuntu system and waits for the reboot to complete:
--- - name: Reboot Debian or Ubuntu and wait for it to complete hosts: all become: true tasks: - name: Reboot the system reboot: - name: Wait for the system to come back up wait_for: port: 22 timeout: 300
In this playbook, the reboot
module is used to reboot the system, and the wait_for
module is used to wait for the system to come back up and be accessible via SSH (on port 22). The become
keyword is used to run the tasks with superuser privileges, and the hosts: all
directive applies the tasks to all hosts in the inventory.
To run this playbook, you can use the ansible-playbook
command, as shown below:
ansible-playbook -i <inventory_file> <playbook_file>
where <inventory_file>
is the path to your Ansible inventory file and <playbook_file>
is the path to the playbook file.
Keep in mind that this is just an example playbook and the exact steps may vary depending on your specific needs and configuration. It is always a good idea to refer to the official Ansible documentation for detailed instructions and further information.