added check and reboot action
This commit is contained in:
@@ -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: Reboot machine
|
||||
command: /sbin/reboot now
|
||||
async: 1
|
||||
poll: 0
|
||||
when: reboot.stat.exists == true
|
||||
|
||||
- name: Report if reboot is required
|
||||
ansible.builtin.debug:
|
||||
msg: "Reboot is required"
|
||||
when: reboot_required.stat.exists
|
||||
- name: Pause for 15 seconds
|
||||
ansible.builtin.pause:
|
||||
seconds: 15
|
||||
|
||||
- name: Wait for systems to become reachable
|
||||
wait_for_connection:
|
||||
Reference in New Issue
Block a user