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