You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- name: Patch Task 1 - upgrade kernel package on RHEL/CentOS server
3
+
ansible.builtin.yum:
4
+
name="kernel"
5
+
state=latest
6
+
when: app_process_check.stdout == "process_not_running" and ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux' or ansible_distribution == 'Rocky Linux'
7
+
register: yum_update
8
+
9
+
- name: Patch Task 2 - check if reboot required after kernel update on CentOS/RedHat servers
10
+
ansible.builtin.shell: KERNEL_NEW=$(rpm -q --last kernel |head -1 | awk '{print $1}' | sed 's/kernel-//'); KERNEL_NOW=$(uname -r); if [[ $KERNEL_NEW != $KERNEL_NOW ]]; then echo "reboot_needed"; else echo "reboot_not_needed"; fi
11
+
when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux'
12
+
ignore_errors: true
13
+
register: reboot_required
14
+
15
+
- name: Patch Task 3 - Reboot CentOS/RedHat systems if kernel updated
16
+
ansible.builtin.command: shutdown -r +1 "Rebooting CentOS/RedHat Servers After Kernel Patching"
17
+
ansible.builtin.async: 0
18
+
poll: 0
19
+
when: reboot_required.stdout == "reboot_needed" and (ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux' or ansible_distribution == 'Rocky Linux')
0 commit comments