From 6ddbaeb0859c716818cc1cfaca6480ae1d12731b Mon Sep 17 00:00:00 2001 From: Jeffrey Cutter Date: Mon, 25 Mar 2024 22:30:38 +0800 Subject: [PATCH] Add option to unload kernel modules before running leapp upgrade. (#168) * Add option to unload kernel modules before running leapp upgrade. * Fix lint. --- changelogs/fragments/kernel_modules_unload.yml | 4 ++++ roles/upgrade/README.md | 1 + roles/upgrade/defaults/main.yml | 1 + roles/upgrade/tasks/leapp-upgrade.yml | 4 ++++ roles/upgrade/tasks/redhat-upgrade-tool-upgrade.yml | 4 ++++ roles/upgrade/tasks/rmmod-kernel-modules.yml | 7 +++++++ 6 files changed, 21 insertions(+) create mode 100644 changelogs/fragments/kernel_modules_unload.yml create mode 100644 roles/upgrade/tasks/rmmod-kernel-modules.yml diff --git a/changelogs/fragments/kernel_modules_unload.yml b/changelogs/fragments/kernel_modules_unload.yml new file mode 100644 index 0000000..391b936 --- /dev/null +++ b/changelogs/fragments/kernel_modules_unload.yml @@ -0,0 +1,4 @@ +--- +minor_changes: + - Add option to unload kernel modules prior to running leapp upgrade (kernel_modules_to_unload_before_upgrade). +... diff --git a/roles/upgrade/README.md b/roles/upgrade/README.md index 2cb0b90..a597eca 100644 --- a/roles/upgrade/README.md +++ b/roles/upgrade/README.md @@ -21,6 +21,7 @@ Additionally a list of any non-Red Hat RPM packages that were installed on the s | async_poll_interval | 60 | Variable used to set the asynchronous task polling internal value (in seconds) | check_leapp_analysis_results| true | Allows for running remediation and going straight to upgrade without re-running analysis. | | post_upgrade_update | true | Boolean to decide if after the upgrade is performed a dnf update will run| +| kernel_modules_to_unload_before_upgrade | [] | A list of kernel modules to be unloaded prior to running leapp. | ## Satellite variables diff --git a/roles/upgrade/defaults/main.yml b/roles/upgrade/defaults/main.yml index 2e64c97..b57d629 100644 --- a/roles/upgrade/defaults/main.yml +++ b/roles/upgrade/defaults/main.yml @@ -127,4 +127,5 @@ async_poll_interval: 60 check_leapp_analysis_results: true +kernel_modules_to_unload_before_upgrade: [] ... diff --git a/roles/upgrade/tasks/leapp-upgrade.yml b/roles/upgrade/tasks/leapp-upgrade.yml index e33a28e..620cd54 100644 --- a/roles/upgrade/tasks/leapp-upgrade.yml +++ b/roles/upgrade/tasks/leapp-upgrade.yml @@ -51,6 +51,10 @@ "{{ repo_files_to_remove_at_upgrade }}" when: leapp_upgrade_type == "custom" +- name: leapp-upgrade | Include rmmod-kernel-modules.yml + ansible.builtin.include_tasks: rmmod-kernel-modules.yml + loop: "{{ kernel_modules_to_unload_before_upgrade }}" + - name: leapp-upgrade | Start Leapp OS upgrade ansible.builtin.shell: > set -o pipefail; diff --git a/roles/upgrade/tasks/redhat-upgrade-tool-upgrade.yml b/roles/upgrade/tasks/redhat-upgrade-tool-upgrade.yml index 79de917..5b854ad 100644 --- a/roles/upgrade/tasks/redhat-upgrade-tool-upgrade.yml +++ b/roles/upgrade/tasks/redhat-upgrade-tool-upgrade.yml @@ -72,6 +72,10 @@ state: present when: leapp_upgrade_type == "custom" +- name: redhat-upgrade-tool-upgrade | Include rmmod-kernel-modules.yml + ansible.builtin.include_tasks: rmmod-kernel-modules.yml + loop: "{{ kernel_modules_to_unload_before_upgrade }}" + # --cleanup-post removes Red Hat signed RHEL 6 packages and in theory should be safe. - name: redhat-upgrade-tool-upgrade | Run redhat-upgrade-tool ansible.builtin.shell: > diff --git a/roles/upgrade/tasks/rmmod-kernel-modules.yml b/roles/upgrade/tasks/rmmod-kernel-modules.yml new file mode 100644 index 0000000..0fd52bd --- /dev/null +++ b/roles/upgrade/tasks/rmmod-kernel-modules.yml @@ -0,0 +1,7 @@ +--- +- name: rmmod-kernel-modules | Unload module {{ item }} + community.general.modprobe: + name: "{{ item }}" + state: absent + +...