Skip to content

Commit 0ccc97f

Browse files
committed
sap_hana_preconfigure: Further improvements for setting kernel args
- Only use dict contents for determining kernel command line dependencies for RHEL releases - Set and display the grubby command line before calling the handler Signed-off-by: Bernd Finger <bfinger@redhat.com>
1 parent 48f981c commit 0ccc97f

File tree

5 files changed

+49
-29
lines changed

5 files changed

+49
-29
lines changed

roles/sap_hana_preconfigure/handlers/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474

7575
- name: "Run grubby for configuring kernel command line entries for SAP"
7676
ansible.builtin.command:
77-
cmd: grubby --args="{{ __sap_hana_preconfigure_boot_command_line_args_final | trim }}" --update-kernel=ALL
77+
cmd: "{{ __sap_hana_preconfigure_fact_grubby_command }}"
7878
changed_when: true
7979
listen: __sap_hana_preconfigure_grubby_update_handler
8080
notify: __sap_hana_preconfigure_reboot_handler

roles/sap_hana_preconfigure/tasks/RedHat/generic/configure-c-states-for-lower-latency.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@
1010
loop_control:
1111
loop_var: __sap_hana_preconfigure_kernel_arg_line_item
1212
when:
13+
- __sap_hana_preconfigure_boot_command_line_args['c-states']['arch'] is defined
1314
- ansible_architecture in __sap_hana_preconfigure_boot_command_line_args['c-states']['arch']

roles/sap_hana_preconfigure/tasks/RedHat/generic/configure-thp.yml

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,39 @@
1212
ansible.builtin.set_fact:
1313
__sap_hana_preconfigure_fact_thp: "{{ __sap_hana_preconfigure_boot_command_line_args['thp']['args'][0].split('=')[1] }}"
1414
when:
15+
- __sap_hana_preconfigure_boot_command_line_args['thp']['arch'] is defined
1516
- sap_hana_preconfigure_thp is undefined or sap_hana_preconfigure_thp | length == 0
1617

17-
- name: Add boot command line args for configuring THP
18-
ansible.builtin.set_fact:
19-
__sap_hana_preconfigure_boot_command_line_args_final: >-
20-
{{ __sap_hana_preconfigure_boot_command_line_args_final + ['transparent_hugepage=' + __sap_hana_preconfigure_fact_thp] }}
18+
- name: Add boot command line args for configuring THP if applicable
19+
when:
20+
- (sap_hana_preconfigure_thp is defined and sap_hana_preconfigure_thp | length > 0)
21+
or __sap_hana_preconfigure_boot_command_line_args['thp']['arch'] is defined
22+
block:
2123

22-
- name: Configure - Get initial status of THP
23-
ansible.builtin.command: cat /sys/kernel/mm/transparent_hugepage/enabled
24-
register: __sap_hana_preconfigure_register_thp_status_before
25-
changed_when: false
24+
- name: Add boot command line args for configuring THP
25+
ansible.builtin.set_fact:
26+
__sap_hana_preconfigure_boot_command_line_args_final: >-
27+
{{ __sap_hana_preconfigure_boot_command_line_args_final
28+
+ ['transparent_hugepage=' + __sap_hana_preconfigure_fact_thp] }}
2629
27-
- name: Set THP to '{{ __sap_hana_preconfigure_fact_thp }}' on the running system
28-
ansible.builtin.shell: echo '{{ __sap_hana_preconfigure_fact_thp }}' > /sys/kernel/mm/transparent_hugepage/enabled
29-
changed_when: true
30-
when:
31-
- not ansible_check_mode
32-
- __sap_hana_preconfigure_register_thp_status_before.stdout.split('[')[1].split(']')[0] != __sap_hana_preconfigure_fact_thp
33-
34-
- name: Configure - Get the status of THP
35-
ansible.builtin.command: cat /sys/kernel/mm/transparent_hugepage/enabled
36-
register: __sap_hana_preconfigure_register_thp_status
37-
ignore_errors: true
38-
changed_when: false
39-
40-
- name: Display the status of THP
41-
ansible.builtin.debug:
42-
var: __sap_hana_preconfigure_register_thp_status.stdout_lines, __sap_hana_preconfigure_register_thp_status.stderr_lines
30+
- name: Configure - Get initial status of THP
31+
ansible.builtin.command: cat /sys/kernel/mm/transparent_hugepage/enabled
32+
register: __sap_hana_preconfigure_register_thp_status_before
33+
changed_when: false
34+
35+
- name: Set THP to '{{ __sap_hana_preconfigure_fact_thp }}' on the running system
36+
ansible.builtin.shell: echo '{{ __sap_hana_preconfigure_fact_thp }}' > /sys/kernel/mm/transparent_hugepage/enabled
37+
changed_when: true
38+
when:
39+
- not ansible_check_mode
40+
- __sap_hana_preconfigure_register_thp_status_before.stdout.split('[')[1].split(']')[0] != __sap_hana_preconfigure_fact_thp
41+
42+
- name: Configure - Get the status of THP
43+
ansible.builtin.command: cat /sys/kernel/mm/transparent_hugepage/enabled
44+
register: __sap_hana_preconfigure_register_thp_status
45+
ignore_errors: true
46+
changed_when: false
47+
48+
- name: Display the status of THP
49+
ansible.builtin.debug:
50+
var: __sap_hana_preconfigure_register_thp_status.stdout_lines, __sap_hana_preconfigure_register_thp_status.stderr_lines

roles/sap_hana_preconfigure/tasks/RedHat/generic/enable-tsx.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,5 @@
99
loop_control:
1010
loop_var: __sap_hana_preconfigure_kernel_arg_line_item
1111
when:
12+
- __sap_hana_preconfigure_boot_command_line_args['tsx']['arch'] is defined
1213
- ansible_architecture in __sap_hana_preconfigure_boot_command_line_args['tsx']['arch']
13-
- ansible_distribution_major_version | int >= 9 or
14-
(ansible_distribution_major_version == '8' and
15-
__sap_hana_preconfigure_fact_ansible_distribution_minor_version | int >= 3)

roles/sap_hana_preconfigure/tasks/RedHat/generic/set-boot-kernel-args.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,20 @@
7777
7878
- name: Display kernel args to be set
7979
ansible.builtin.debug:
80-
msg: "Kernel args to be set: {{ __sap_hana_preconfigure_fact_kernel_args_to_be_set }}"
80+
msg: "Kernel args to be set: '{{ __sap_hana_preconfigure_fact_kernel_args_to_be_set }}'"
81+
82+
- name: Construct the grubby command for configuring the kernel command line entries
83+
ansible.builtin.set_fact:
84+
__sap_hana_preconfigure_fact_grubby_command: >-
85+
grubby --args="{{ __sap_hana_preconfigure_fact_kernel_args_to_be_set | join(' ') | trim }}" --update-kernel=ALL
86+
when:
87+
- __sap_hana_preconfigure_fact_kernel_args_to_be_set | length > 0
88+
89+
- name: Display the grubby command to be run
90+
ansible.builtin.debug:
91+
msg: "Grubby command: '{{ __sap_hana_preconfigure_fact_grubby_command }}'"
92+
when:
93+
- __sap_hana_preconfigure_fact_kernel_args_to_be_set | length > 0
8194

8295
# Reason for noqa: The command does not change anything but if we set 'changed_when: true',
8396
# the handler will not be notified.

0 commit comments

Comments
 (0)