Skip to content

Commit 44fa111

Browse files
HVSharma12richm
authored andcommitted
ci: Handle reboot for transactional update systems
1 parent ab0548e commit 44fa111

File tree

7 files changed

+56
-6
lines changed

7 files changed

+56
-6
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,15 @@ when to reboot the managed host. The role will return the variable
109109
`kernel_settings_reboot_required` (see below) with a value of `true` to indicate
110110
that some change has occurred which needs a reboot to take effect.
111111

112+
### kernel_settings_transactional_update_reboot_ok
113+
114+
This variable is used to handle reboots required by transactional updates.
115+
If a transactional update requires a reboot, the role will proceed with the
116+
reboot if `kernel_settings_transactional_update_reboot_ok` is set to `true`. If set
117+
to `false`, the role will notify the user that a reboot is required, allowing
118+
for custom handling of the reboot requirement. If this variable is not set,
119+
the role will fail to ensure the reboot requirement is not overlooked.
120+
112121
### Variables Exported by the Role
113122

114123
The role will export the following variables:

defaults/main.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,11 @@ kernel_settings_purge: false
4747
# some changes will require the managed host to be rebooted in order to be
4848
# applied, and will set kernel_settings_reboot_required: true
4949
kernel_settings_reboot_ok: false
50+
51+
# This variable is used to handle reboots required by transactional updates.
52+
# If a transactional update requires a reboot, the role will proceed with the
53+
# reboot if `kernel_settings_transactional_update_reboot_ok` is set to `true`. If set
54+
# to `false`, the role will notify the user that a reboot is required, allowing
55+
# for custom handling of the reboot requirement. If this variable is not set,
56+
# the role will fail to ensure the reboot requirement is not overlooked.
57+
kernel_settings_transactional_update_reboot_ok: null

tasks/main.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,30 @@
88
state: present
99
use: "{{ (__kernel_settings_is_ostree | d(false)) |
1010
ternary('ansible.posix.rhel_rpm_ostree', omit) }}"
11+
register: kernel_settings_package_result
12+
13+
- name: Handle reboot for transactional update systems
14+
when:
15+
- __kernel_settings_is_transactional | d(false)
16+
- kernel_settings_package_result is changed
17+
block:
18+
- name: Notify user that reboot is needed to apply changes
19+
debug:
20+
msg: >
21+
Reboot required to apply changes due to transactional updates.
22+
23+
- name: Reboot transactional update systems
24+
reboot:
25+
msg: Rebooting the system to apply transactional update changes.
26+
when: kernel_settings_transactional_update_reboot_ok | bool
27+
28+
- name: Fail if reboot is needed and not set
29+
fail:
30+
msg: >
31+
Reboot is required but not allowed. Please set
32+
'kernel_settings_transactional_update_reboot_ok' to proceed.
33+
when:
34+
- kernel_settings_transactional_update_reboot_ok is none
1135

1236
- name: Ensure required services are enabled and started
1337
service:

tasks/set_vars.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,18 @@
1717
set_fact:
1818
__kernel_settings_is_ostree: "{{ __ostree_booted_stat.stat.exists }}"
1919

20+
- name: Determine if system is transactional update and set flag
21+
when: not __kernel_settings_is_transactional is defined
22+
block:
23+
- name: Check if transactional-update exists in /sbin
24+
stat:
25+
path: /sbin/transactional-update
26+
register: __transactional_update_stat
27+
28+
- name: Set flag if transactional-update exists
29+
set_fact:
30+
__kernel_settings_is_transactional: "{{ __transactional_update_stat.stat.exists }}"
31+
2032
- name: Set platform/version specific variables
2133
include_vars: "{{ lookup('first_found', ffparams) }}"
2234
vars:

tests/vars/tests_SL-Micro.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
__kernel_settings_test_python_pkgs: ["python", "python-configobj"]
3+
__kernel_settings_test_python_cmd: python3

vars/ALP-Dolomite

Lines changed: 0 additions & 3 deletions
This file was deleted.

vars/ALP-Dolomite.yml

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)