From d4b44993a21170f70552e9c84a4a6d0cbc5620ed Mon Sep 17 00:00:00 2001
From: handreas <andreas.hamacher@monash.edu>
Date: Wed, 3 Jun 2020 12:25:40 +0000
Subject: [PATCH] manually removing conflicting modules

---
 roles/upgrade/tasks/main.yml | 43 ++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/roles/upgrade/tasks/main.yml b/roles/upgrade/tasks/main.yml
index 90af1582..8a7ffe5e 100644
--- a/roles/upgrade/tasks/main.yml
+++ b/roles/upgrade/tasks/main.yml
@@ -1,4 +1,44 @@
 ---
+- name: get kernel version
+  shell: uname -r
+  register: uname_r_output
+  check_mode: no
+  changed_when: False
+  
+- name: remove conflicting packages if kernel is going to changed
+  block:
+    - name: see if we have a lustre-client service
+      shell: systemctl status lustre-client
+      register: lustreStatus
+      changed_when: False
+      failed_when: '"could not be found" in lustreStatus.stdout'
+
+    - name: stop lustre
+      service: name=lustre-client state=stopped
+      become: true
+      when: lustreStatus.failed
+
+    - name: remove conflicting packages if kernel is going to changed
+      package:
+        state: absent
+        name: 
+          - kmod-lustre-client
+          - kernel-devel
+      become: true
+    - name: remove mellanox rpms
+      yum:
+        state: absent
+        name:
+          - mlnx-ofa_kernel
+          - mlnx-ofa_kernel-devel
+          - mlnx-ofa_kernel-modules
+          - libibverbs
+          - libgpod
+          - usbmuxd
+          - libmlx5
+          - libmlx4
+      become: true
+  when: uname_r_output.stdout != KERNEL_VERSION
 
 - name: install aptitude
   apt: name=aptitude state=present
@@ -52,6 +92,9 @@
     name:
       - kernel-devel-{{ KERNEL_VERSION }}
       - kernel-{{ KERNEL_VERSION }}
+      - kernel-headers-{{ KERNEL_VERSION }}
+      - kernel-tools-{{ KERNEL_VERSION }}
+      - kernel-tools-libs-{{ KERNEL_VERSION }}
     state: present
   become: true
   when: ansible_os_family=="RedHat"
-- 
GitLab