diff --git a/ansible-scylla-node/tasks/RedHat.yml b/ansible-scylla-node/tasks/RedHat.yml index 891b467c..1a91bca6 100644 --- a/ansible-scylla-node/tasks/RedHat.yml +++ b/ansible-scylla-node/tasks/RedHat.yml @@ -37,18 +37,6 @@ lock_timeout: 60 register: kernel_installed - - name: - package: - name: - - kernel - - kernel-ml - state: absent - - - name: Needs restarting? - command: needs-restarting -r - register: restart_required - ignore_errors: yes - - name: Configure grub2 to boot first entry lineinfile: dest: /etc/default/grub @@ -69,6 +57,11 @@ command: grub2-mkconfig -o /boot/grub2/grub.cfg when: kernel_installed.changed + - name: Needs restarting? + command: needs-restarting -r + register: restart_required + ignore_errors: yes + - name: Reboot host and wait for it to restart reboot: msg: "Reboot initiated by Ansible" @@ -77,7 +70,15 @@ pre_reboot_delay: 0 post_reboot_delay: 30 test_command: whoami - when: (reboot_after_kernel_upgrade|bool and kernel_installed.changed) r restart_required.rc == 1 + when: (reboot_after_kernel_upgrade|bool and kernel_installed.changed) or restart_required.rc == 1 + + - name: Remove old kernels + package: + name: + - kernel + - kernel-ml + state: absent + when: elrepo_kernel|bool and install_type == 'online' and (ansible_distribution == "CentOS" or ansible_distribution == "RedHat") become: true