Skip to content

Commit

Permalink
ci: Handle reboot for transactional update systems
Browse files Browse the repository at this point in the history
  • Loading branch information
HVSharma12 committed Jul 31, 2024
1 parent ab0548e commit 57cdcf7
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 6 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,15 @@ when to reboot the managed host. The role will return the variable
`kernel_settings_reboot_required` (see below) with a value of `true` to indicate
that some change has occurred which needs a reboot to take effect.

### kernel_settings_transactional_update_reboot_ok

This variable is used to handle reboots required by transactional updates.
If a transactional update requires a reboot, the role will proceed with the
reboot if `kernel_settings_transactional_update_reboot_ok` is set to `true`. If set
to `false`, the role will notify the user that a reboot is required, allowing
for custom handling of the reboot requirement. If this variable is not set,
the role will fail to ensure the reboot requirement is not overlooked.

### Variables Exported by the Role

The role will export the following variables:
Expand Down
8 changes: 8 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,11 @@ kernel_settings_purge: false
# some changes will require the managed host to be rebooted in order to be
# applied, and will set kernel_settings_reboot_required: true
kernel_settings_reboot_ok: false

# This variable is used to handle reboots required by transactional updates.
# If a transactional update requires a reboot, the role will proceed with the
# reboot if `kernel_settings_transactional_update_reboot_ok` is set to `true`. If set
# to `false`, the role will notify the user that a reboot is required, allowing
# for custom handling of the reboot requirement. If this variable is not set,
# the role will fail to ensure the reboot requirement is not overlooked.
kernel_settings_transactional_update_reboot_ok: null
24 changes: 24 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,30 @@
state: present
use: "{{ (__kernel_settings_is_ostree | d(false)) |
ternary('ansible.posix.rhel_rpm_ostree', omit) }}"
register: kernel_settings_package_result

- name: Handle reboot for transactional update systems
when:
- __kernel_settings_is_transactional | d(false)
- kernel_settings_package_result is changed
block:
- name: Notify user that reboot is needed to apply changes
debug:
msg: >
Reboot required to apply changes due to transactional updates.
- name: Reboot transactional update systems
reboot:
msg: Rebooting the system to apply transactional update changes.
when: kernel_settings_transactional_update_reboot_ok | bool

- name: Fail if reboot is needed and not set
fail:
msg: >
Reboot is required but not allowed. Please set
'kernel_settings_transactional_update_reboot_ok' to proceed.
when:
- kernel_settings_transactional_update_reboot_ok is none

- name: Ensure required services are enabled and started
service:
Expand Down
12 changes: 12 additions & 0 deletions tasks/set_vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@
set_fact:
__kernel_settings_is_ostree: "{{ __ostree_booted_stat.stat.exists }}"

- name: Determine if system is transactional update and set flag
when: not __kernel_settings_is_transactional is defined
block:
- name: Check if transactional-update exists in /sbin
stat:
path: /sbin/transactional-update
register: __transactional_update_stat

- name: Set flag if transactional-update exists
set_fact:
__kernel_settings_is_transactional: "{{ __transactional_update_stat.stat.exists }}"

- name: Set platform/version specific variables
include_vars: "{{ lookup('first_found', ffparams) }}"
vars:
Expand Down
3 changes: 3 additions & 0 deletions tests/vars/tests_SL-Micro.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
__kernel_settings_test_python_pkgs: ["python", "python-configobj"]
__kernel_settings_test_python_cmd: python3
3 changes: 0 additions & 3 deletions vars/ALP-Dolomite

This file was deleted.

3 changes: 0 additions & 3 deletions vars/ALP-Dolomite.yml

This file was deleted.

0 comments on commit 57cdcf7

Please sign in to comment.