2
0

added check and reboot action

This commit is contained in:
2024-06-06 21:41:44 +02:00
parent 7cb0ddd53c
commit f776e37cc7

View File

@@ -1,16 +1,23 @@
---
- name: Check if system reboot is required
hosts: "{{ my_hosts | d([]) }}"
become: true
hosts: all
become: yes
become_user: root
tasks:
- name: Check if system reboot is required
become: true
ansible.builtin.stat:
path: /var/run/reboot-required
register: reboot_required
- name: Check if a reboot is required
register: reboot
stat: path=/var/run/reboot-required get_md5=no
- name: Report if reboot is required
ansible.builtin.debug:
msg: "Reboot is required"
when: reboot_required.stat.exists
- name: Reboot machine
command: /sbin/reboot now
async: 1
poll: 0
when: reboot.stat.exists == true
- name: Pause for 15 seconds
ansible.builtin.pause:
seconds: 15
- name: Wait for systems to become reachable
wait_for_connection: