From a651f1b8ac9a2b92c5b68241913b6583ca90e7ef Mon Sep 17 00:00:00 2001 From: Wabri <12409541+Wabri@users.noreply.github.com> Date: Tue, 6 Feb 2024 13:08:55 +0100 Subject: [PATCH 1/7] fix(sap_hana_preconfigure/tasks/SLES): update kernel paramenters Closes #337 --- .../tasks/SLES/configuration.yml | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/roles/sap_hana_preconfigure/tasks/SLES/configuration.yml b/roles/sap_hana_preconfigure/tasks/SLES/configuration.yml index b588e9d88..73b2db850 100644 --- a/roles/sap_hana_preconfigure/tasks/SLES/configuration.yml +++ b/roles/sap_hana_preconfigure/tasks/SLES/configuration.yml @@ -32,6 +32,26 @@ ansible.builtin.debug: var: __sap_hana_preconfigure_fact_solution_configured +- name: Set GRUB entries + when: __sap_hana_preconfigure_run_saptune + block: + - name: Set GRUB entries # noqa yaml[line-length] + ansible.builtin.lineinfile: + path: /etc/default/grub + regexp: "^GRUB_CMDLINE_LINUX_DEFAULT=" + line: 'GRUB_CMDLINE_LINUX_DEFAULT="splash=silent mitigations=auto quiet numa_balancing=disable transparent_hugepage=never intel_idle.max_cstate=1 processor.max_cstate=1 audit=1"' + register: set_grub_entries + + - name: GRUB mkconfig # noqa command-instead-of-shell no-handler + ansible.builtin.shell: + cmd: grub2-mkconfig -o /boot/grub2/grub.cfg + when: set_grub_entries.changed + + - name: GRUB.cfg permissions + ansible.builtin.file: + path: /boot/grub2/grub.cfg + mode: "0600" + - name: Enable sapconf when: not __sap_hana_preconfigure_run_saptune block: From fb32d0d80c01a462793b17285856e1f9e7553470 Mon Sep 17 00:00:00 2001 From: Wabri <12409541+Wabri@users.noreply.github.com> Date: Thu, 8 Feb 2024 17:08:02 +0100 Subject: [PATCH 2/7] fix(sap_hana_preconfigure): split every element independently --- .../tasks/SLES/configuration.yml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/roles/sap_hana_preconfigure/tasks/SLES/configuration.yml b/roles/sap_hana_preconfigure/tasks/SLES/configuration.yml index 73b2db850..ffbf1e837 100644 --- a/roles/sap_hana_preconfigure/tasks/SLES/configuration.yml +++ b/roles/sap_hana_preconfigure/tasks/SLES/configuration.yml @@ -35,17 +35,26 @@ - name: Set GRUB entries when: __sap_hana_preconfigure_run_saptune block: - - name: Set GRUB entries # noqa yaml[line-length] + - name: Set GRUB entries ansible.builtin.lineinfile: path: /etc/default/grub - regexp: "^GRUB_CMDLINE_LINUX_DEFAULT=" - line: 'GRUB_CMDLINE_LINUX_DEFAULT="splash=silent mitigations=auto quiet numa_balancing=disable transparent_hugepage=never intel_idle.max_cstate=1 processor.max_cstate=1 audit=1"' + regexp: '^(GRUB_CMDLINE_LINUX_DEFAULT=(?!.* {{ item }}).*). *$' + line: "\\1 {{ item }}\"" register: set_grub_entries + with_items: + - "splash=silent" + - "mitigations=auto" + - "quiet" + - "numa_balancing=disable" + - "transparent_hugepage=never" + - "intel_idle.max_cstate=1" + - "processor.max_cstate=1" + - "audit=1" - name: GRUB mkconfig # noqa command-instead-of-shell no-handler ansible.builtin.shell: cmd: grub2-mkconfig -o /boot/grub2/grub.cfg - when: set_grub_entries.changed + when: set_grub_entries.results | selectattr('changed', 'equalto', true) | list | length > 0 - name: GRUB.cfg permissions ansible.builtin.file: From cc20bda7d0ea549843288899145aa2011c613b7c Mon Sep 17 00:00:00 2001 From: Wabri <12409541+Wabri@users.noreply.github.com> Date: Fri, 9 Feb 2024 12:30:57 +0100 Subject: [PATCH 3/7] fix(sap_hana_preconfigure): solve the linting problem - remove a trailing space - add a `noqa no-changed-when` in order to prevent a false-positive of the linting --- roles/sap_hana_preconfigure/tasks/SLES/configuration.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/roles/sap_hana_preconfigure/tasks/SLES/configuration.yml b/roles/sap_hana_preconfigure/tasks/SLES/configuration.yml index ffbf1e837..b7a484d20 100644 --- a/roles/sap_hana_preconfigure/tasks/SLES/configuration.yml +++ b/roles/sap_hana_preconfigure/tasks/SLES/configuration.yml @@ -35,13 +35,16 @@ - name: Set GRUB entries when: __sap_hana_preconfigure_run_saptune block: - - name: Set GRUB entries + # Reason for noqa: the regex do a check on the element before apply the + # changed item, this prevent a replace to an element that is already in the + # configuration + - name: Set GRUB entries # noqa no-changed-when ansible.builtin.lineinfile: path: /etc/default/grub regexp: '^(GRUB_CMDLINE_LINUX_DEFAULT=(?!.* {{ item }}).*). *$' line: "\\1 {{ item }}\"" register: set_grub_entries - with_items: + with_items: - "splash=silent" - "mitigations=auto" - "quiet" From 186e97aefccc9c8835c949a4369c20ddaf790189 Mon Sep 17 00:00:00 2001 From: Wabri <12409541+Wabri@users.noreply.github.com> Date: Fri, 9 Feb 2024 12:40:28 +0100 Subject: [PATCH 4/7] fix(sap_hana_preconfigure): fix some more typos --- roles/sap_hana_preconfigure/tasks/SLES/configuration.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/roles/sap_hana_preconfigure/tasks/SLES/configuration.yml b/roles/sap_hana_preconfigure/tasks/SLES/configuration.yml index b7a484d20..f66cf53e8 100644 --- a/roles/sap_hana_preconfigure/tasks/SLES/configuration.yml +++ b/roles/sap_hana_preconfigure/tasks/SLES/configuration.yml @@ -35,9 +35,9 @@ - name: Set GRUB entries when: __sap_hana_preconfigure_run_saptune block: - # Reason for noqa: the regex do a check on the element before apply the + # Reason for noqa: the regex do a check on the element before apply the # changed item, this prevent a replace to an element that is already in the - # configuration + # configuration - name: Set GRUB entries # noqa no-changed-when ansible.builtin.lineinfile: path: /etc/default/grub @@ -54,7 +54,7 @@ - "processor.max_cstate=1" - "audit=1" - - name: GRUB mkconfig # noqa command-instead-of-shell no-handler + - name: GRUB mkconfig # noqa command-instead-of-shell no-handler no-changed-when ansible.builtin.shell: cmd: grub2-mkconfig -o /boot/grub2/grub.cfg when: set_grub_entries.results | selectattr('changed', 'equalto', true) | list | length > 0 From 6fcc1a189a31084f585d137e9ed7ec2032f8a4e7 Mon Sep 17 00:00:00 2001 From: Wabri <12409541+Wabri@users.noreply.github.com> Date: Fri, 9 Feb 2024 14:51:45 +0100 Subject: [PATCH 5/7] feat(sap_hana_preconfigure): update grub using handlers Some experiments using handlers --- .../tasks/SLES/configuration.yml | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/roles/sap_hana_preconfigure/tasks/SLES/configuration.yml b/roles/sap_hana_preconfigure/tasks/SLES/configuration.yml index f66cf53e8..1df107982 100644 --- a/roles/sap_hana_preconfigure/tasks/SLES/configuration.yml +++ b/roles/sap_hana_preconfigure/tasks/SLES/configuration.yml @@ -35,9 +35,10 @@ - name: Set GRUB entries when: __sap_hana_preconfigure_run_saptune block: - # Reason for noqa: the regex do a check on the element before apply the - # changed item, this prevent a replace to an element that is already in the - # configuration + # Reason for noqa: + # no-changed-when: the regex do a check on the element before apply the + # changed item, this prevent a replace to an element that is already in + # the configuration - name: Set GRUB entries # noqa no-changed-when ansible.builtin.lineinfile: path: /etc/default/grub @@ -54,15 +55,10 @@ - "processor.max_cstate=1" - "audit=1" - - name: GRUB mkconfig # noqa command-instead-of-shell no-handler no-changed-when - ansible.builtin.shell: - cmd: grub2-mkconfig -o /boot/grub2/grub.cfg + - name: Trigger grub update if necessary + ansible.builtin.meta: noop when: set_grub_entries.results | selectattr('changed', 'equalto', true) | list | length > 0 - - - name: GRUB.cfg permissions - ansible.builtin.file: - path: /boot/grub2/grub.cfg - mode: "0600" + notify: GRUB_post-update_configuration - name: Enable sapconf when: not __sap_hana_preconfigure_run_saptune @@ -124,3 +120,16 @@ - name: Ensure solution was successful ansible.builtin.command: "saptune solution verify {{ sap_hana_preconfigure_saptune_solution }}" changed_when: false # We're only checking, not changing! + + handlers: + - name: GRUB_post-update_configuration + block: + - name: GRUB mkconfig + ansible.builtin.shell: + cmd: grub2-mkconfig -o /boot/grub2/grub.cfg + + - name: GRUB.cfg permissions + ansible.builtin.file: + path: /boot/grub2/grub.cfg + mode: "0600" + From 11792897cdb54a2c3cc648e8b642dab419410e39 Mon Sep 17 00:00:00 2001 From: Wabri <12409541+Wabri@users.noreply.github.com> Date: Fri, 9 Feb 2024 15:07:01 +0100 Subject: [PATCH 6/7] fix(sap_hana_preconfigure): wrong placement of handlers --- .../tasks/SLES/configuration.yml | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/roles/sap_hana_preconfigure/tasks/SLES/configuration.yml b/roles/sap_hana_preconfigure/tasks/SLES/configuration.yml index 1df107982..c90076c7c 100644 --- a/roles/sap_hana_preconfigure/tasks/SLES/configuration.yml +++ b/roles/sap_hana_preconfigure/tasks/SLES/configuration.yml @@ -34,10 +34,21 @@ - name: Set GRUB entries when: __sap_hana_preconfigure_run_saptune + handlers: + - name: GRUB_post-update_configuration + block: + - name: GRUB mkconfig + ansible.builtin.shell: + cmd: grub2-mkconfig -o /boot/grub2/grub.cfg + + - name: GRUB.cfg permissions + ansible.builtin.file: + path: /boot/grub2/grub.cfg + mode: "0600" block: - # Reason for noqa: - # no-changed-when: the regex do a check on the element before apply the - # changed item, this prevent a replace to an element that is already in + # Reason for noqa: + # no-changed-when: the regex do a check on the element before apply the + # changed item, this prevent a replace to an element that is already in # the configuration - name: Set GRUB entries # noqa no-changed-when ansible.builtin.lineinfile: @@ -120,16 +131,3 @@ - name: Ensure solution was successful ansible.builtin.command: "saptune solution verify {{ sap_hana_preconfigure_saptune_solution }}" changed_when: false # We're only checking, not changing! - - handlers: - - name: GRUB_post-update_configuration - block: - - name: GRUB mkconfig - ansible.builtin.shell: - cmd: grub2-mkconfig -o /boot/grub2/grub.cfg - - - name: GRUB.cfg permissions - ansible.builtin.file: - path: /boot/grub2/grub.cfg - mode: "0600" - From 43167ee63a681e1a587f7eb485142b859a988894 Mon Sep 17 00:00:00 2001 From: Wabri <12409541+Wabri@users.noreply.github.com> Date: Tue, 13 Feb 2024 16:08:38 +0100 Subject: [PATCH 7/7] fix(sap_hana_preconfigure/tasks/SLES): update noop with bin/true --- .../sap_hana_preconfigure/tasks/SLES/configuration.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/roles/sap_hana_preconfigure/tasks/SLES/configuration.yml b/roles/sap_hana_preconfigure/tasks/SLES/configuration.yml index c90076c7c..c5a3c8070 100644 --- a/roles/sap_hana_preconfigure/tasks/SLES/configuration.yml +++ b/roles/sap_hana_preconfigure/tasks/SLES/configuration.yml @@ -66,8 +66,14 @@ - "processor.max_cstate=1" - "audit=1" - - name: Trigger grub update if necessary - ansible.builtin.meta: noop + # Reason for noqa: + # no-changed-when: there is already a check on the `when` argument that + # loop over all the results of the previous task and if some of the results + # changed the grub configuration file the `GRUB_post-update_configuration` + # handler will be notify, in the other hands if none of the item changed + # the configuration file no handler will be notify + - name: Trigger grub update if necessary # noqa no-changed-when + ansible.builtin.command: /bin/true when: set_grub_entries.results | selectattr('changed', 'equalto', true) | list | length > 0 notify: GRUB_post-update_configuration