From 7f07dcd02614cfdacebc57868b2a463a2c423b29 Mon Sep 17 00:00:00 2001 From: Adam DeConinck Date: Fri, 11 Sep 2020 18:29:35 +0000 Subject: [PATCH 1/2] Ensure we have kernel-headers before installing driver --- tasks/install-redhat.yml | 64 ++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 36 deletions(-) diff --git a/tasks/install-redhat.yml b/tasks/install-redhat.yml index 65ec4ba..bea013c 100644 --- a/tasks/install-redhat.yml +++ b/tasks/install-redhat.yml @@ -1,4 +1,32 @@ --- +# We have to do this because the CentOS mirrors don't keep kernel-headers, etc +# for older kernels. +- name: ensure we have kernel-headers installed for the current kernel + block: + - name: attempt to install kernel support packages for current version + yum: + name: "{{ item }}-{{ ansible_kernel }}" + state: present + with_items: + - "kernel-headers" + - "kernel-tools" + - "kernel-tools-libs" + - "kernel-devel" + - "kernel-debug-devel" + environment: "{{proxy_env if proxy_env is defined else {}}}" + rescue: + - name: update the kernel to latest version so we have a supported version + yum: + name: + - "kernel" + - "kernel-headers" + - "kernel-tools" + - "kernel-tools-libs" + - "kernel-devel" + - "kernel-debug-devel" + state: latest + environment: "{{proxy_env if proxy_env is defined else {}}}" + - name: add epel repo yum_repository: name: epel @@ -26,39 +54,3 @@ register: install_driver environment: "{{proxy_env if proxy_env is defined else {}}}" -# The driver package pulls in the latest kernel-headers package, but not the -# latest kernel. Check to see if there is a mismatch. - -- name: check kernel versions - yum: - list: kernel - register: yum_list - -- name: register installed kernel version - debug: - msg: "{{ yum_list.results | selectattr('yumstate', 'equalto', 'installed') | list }}" - register: kernel_version - -- name: check kernel-headers versions - yum: - list: kernel-headers - register: yum_list - -- name: register installed kernel-headers version - debug: - msg: "{{ yum_list.results | selectattr('yumstate', 'equalto', 'installed') | list }}" - register: kernel_headers_version - -- name: update kernel if headers don't match - yum: - name: - - kernel - - kernel-tools - - kernel-tools-libs - - kernel-devel - - kernel-debug-devel - - kernel-headers - state: latest - register: kernel_update - when: kernel_version.msg[0].release != kernel_headers_version.msg[0].release - environment: "{{proxy_env if proxy_env is defined else {}}}" From 8ba1df5866c7d4b84121b0327c874d2e3447dec8 Mon Sep 17 00:00:00 2001 From: Adam DeConinck Date: Fri, 11 Sep 2020 18:42:45 +0000 Subject: [PATCH 2/2] reboot after kernel update --- tasks/install-redhat.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tasks/install-redhat.yml b/tasks/install-redhat.yml index bea013c..6f0225a 100644 --- a/tasks/install-redhat.yml +++ b/tasks/install-redhat.yml @@ -26,6 +26,8 @@ - "kernel-debug-devel" state: latest environment: "{{proxy_env if proxy_env is defined else {}}}" + - name: reboot to pick up the new kernel + reboot: - name: add epel repo yum_repository: