2023-10-24 10:19:06 +02:00
|
|
|
- hosts: odroid_cluster
|
|
|
|
name: Check for reboot
|
|
|
|
become: true
|
2024-08-18 23:49:57 +02:00
|
|
|
gather_facts: false
|
2023-10-24 10:19:06 +02:00
|
|
|
tasks:
|
|
|
|
- name: Check if file exists using stat module
|
|
|
|
stat:
|
|
|
|
path: /var/run/reboot-required
|
|
|
|
register: file_status
|
|
|
|
|
|
|
|
- name: Print file status
|
|
|
|
debug:
|
|
|
|
var: file_status.stat.exists
|
|
|
|
- name: Reboot the server
|
|
|
|
tags: reboot
|
2024-08-18 23:49:57 +02:00
|
|
|
become: true
|
2023-10-24 10:19:06 +02:00
|
|
|
become_user: root
|
|
|
|
shell: "sleep 5 && reboot"
|
|
|
|
async: 1
|
|
|
|
poll: 0
|
|
|
|
when: file_status.stat.exists == true
|
|
|
|
|
|
|
|
- name: (reboot) Wait for server to restart
|
|
|
|
ansible.builtin.wait_for_connection:
|
|
|
|
delay: 10
|
|
|
|
timeout: 300
|