diff --git a/roles/sap_general_preconfigure/handlers/main.yml b/roles/sap_general_preconfigure/handlers/main.yml index cdbd8a607..e54f6dd56 100644 --- a/roles/sap_general_preconfigure/handlers/main.yml +++ b/roles/sap_general_preconfigure/handlers/main.yml @@ -43,6 +43,7 @@ - name: Remount /dev/shm # noqa command-instead-of-module no-changed-when ansible.builtin.command: mount -o remount /dev/shm listen: __sap_general_preconfigure_mount_tmpfs_handler + tags: molecule-idempotence-notest - name: Check if /dev/shm is available ansible.builtin.command: df -h /dev/shm diff --git a/roles/sap_general_preconfigure/tasks/RedHat/generic/configure-kernel-parameters.yml b/roles/sap_general_preconfigure/tasks/RedHat/generic/configure-kernel-parameters.yml index a1d75dfd0..f498cdce8 100644 --- a/roles/sap_general_preconfigure/tasks/RedHat/generic/configure-kernel-parameters.yml +++ b/roles/sap_general_preconfigure/tasks/RedHat/generic/configure-kernel-parameters.yml @@ -13,11 +13,25 @@ loop_control: loop_var: line_item +# Note: The sole purpose of the following two tasks is to collect the current value(s) of the kernel parameters +# in sap_general_preconfigure_etc_sysctl_sap_conf so that the "Reload kernel parameters from file ..." task +# can correctly report its 'changed' state. See also https://github.com/sap-linuxlab/community.sap_install/issues/752 . +- name: Construct the command for getting all current parameters of file '{{ sap_general_preconfigure_etc_sysctl_sap_conf }}' + ansible.builtin.command: awk 'BEGIN{FS="="; printf ("sysctl ")}{printf ("%s ", $1)}' "{{ sap_general_preconfigure_etc_sysctl_sap_conf }}" + register: __sap_general_preconfigure_register_sap_conf_sysctl_command + changed_when: false + +# Reason for noqa: The command module tries to run the complete string as a single command +- name: Get all currently active values of the parameters of file '{{ sap_general_preconfigure_etc_sysctl_sap_conf }}' # noqa command-instead-of-shell + ansible.builtin.shell: "{{ __sap_general_preconfigure_register_sap_conf_sysctl_command.stdout }}" + register: __sap_general_preconfigure_register_sap_conf_sysctl_p_output_old + changed_when: false + - name: Reload kernel parameters from file '{{ sap_general_preconfigure_etc_sysctl_sap_conf }}' ansible.builtin.command: sysctl -p "{{ sap_general_preconfigure_etc_sysctl_sap_conf }}" - register: __sap_general_preconfigure_register_sap_conf_sysctl_p_output - changed_when: true + register: __sap_general_preconfigure_register_sap_conf_sysctl_p_output_new + changed_when: __sap_general_preconfigure_register_sap_conf_sysctl_p_output_old.stdout != __sap_general_preconfigure_register_sap_conf_sysctl_p_output_new.stdout - name: Display kernel parameters after setting kernel.pid_max ansible.builtin.debug: - var: __sap_general_preconfigure_register_sap_conf_sysctl_p_output.stdout_lines + var: __sap_general_preconfigure_register_sap_conf_sysctl_p_output_new.stdout_lines diff --git a/roles/sap_general_preconfigure/tasks/RedHat/installation.yml b/roles/sap_general_preconfigure/tasks/RedHat/installation.yml index 1fa7b2afb..55ff79239 100644 --- a/roles/sap_general_preconfigure/tasks/RedHat/installation.yml +++ b/roles/sap_general_preconfigure/tasks/RedHat/installation.yml @@ -74,6 +74,7 @@ # and then having to compare the output against the list of desired repos - name: Run the subscription-manager command # noqa no-changed-when ansible.builtin.command: "{{ __sap_general_preconfigure_fact_subscription_manager_command }}" + tags: molecule-idempotence-notest # Reason for noqa: We need the output of the yum command - name: Get list of enabled repositories @@ -104,6 +105,7 @@ when: - sap_general_preconfigure_set_minor_release - __sap_general_preconfigure_register_subscription_manager_release.stdout != ansible_distribution_version + tags: molecule-idempotence-notest - name: Ensure that the required package groups are installed, RHEL except 8.1 ansible.builtin.package: @@ -120,6 +122,7 @@ ansible.builtin.command: "yum install {{ sap_general_preconfigure_packagegroups | join(' ') }} --nobest --exclude=kernel* -y" register: __sap_general_preconfigure_register_yum_group_install when: ansible_distribution_version == '8.1' + tags: molecule-idempotence-notest # possible replacement once we no longer need Ansible 2.9 compatibility: #- name: Ensure that the required package groups are installed, RHEL 8 and 9 diff --git a/roles/sap_hana_preconfigure/tasks/RedHat/installation.yml b/roles/sap_hana_preconfigure/tasks/RedHat/installation.yml index a7a51f79f..1ffcd4be5 100644 --- a/roles/sap_hana_preconfigure/tasks/RedHat/installation.yml +++ b/roles/sap_hana_preconfigure/tasks/RedHat/installation.yml @@ -42,6 +42,7 @@ - name: Enable required repositories # noqa no-changed-when ansible.builtin.command: "subscription-manager repos {{ __sap_hana_preconfigure_fact_required_repos_args | map('quote') | join(' ') }}" register: __sap_hana_preconfigure_register_subscription_enable_repos + tags: molecule-idempotence-notest - name: Display the output of the subscription-manager repos --enable command ansible.builtin.debug: diff --git a/roles/sap_hana_preconfigure/tasks/sapnote/2055470.yml b/roles/sap_hana_preconfigure/tasks/sapnote/2055470.yml index 286c35ee5..8bd97e5ec 100644 --- a/roles/sap_hana_preconfigure/tasks/sapnote/2055470.yml +++ b/roles/sap_hana_preconfigure/tasks/sapnote/2055470.yml @@ -66,11 +66,25 @@ loop_control: loop_var: line_item -# Reason for noqa: We unconditionally reload the kernel parameters without first checking the current values - - name: Reload kernel parameters from file '/etc/sysctl.d/ibm_largesend.conf' # noqa no-changed-when +# Note: The sole purpose of the following two tasks is to collect the current value(s) of the kernel parameters +# in '/etc/sysctl.d/ibm_largesend.conf' so that the "Reload kernel parameters from file ..." task +# can correctly report its 'changed' state. See also https://github.com/sap-linuxlab/community.sap_install/issues/752 . + - name: Construct the command for getting all current parameters of file '/etc/sysctl.d/ibm_largesend.conf' + ansible.builtin.command: awk 'BEGIN{FS="="; printf ("sysctl ")}{printf ("%s ", $1)}' /etc/sysctl.d/ibm_largesend.conf + register: __sap_hana_preconfigure_register_ibm_largesend_sysctl_command + changed_when: false + +# Reason for noqa: The command module tries to run the complete string as a single command + - name: Get all currently active values of the parameters of file '/etc/sysctl.d/ibm_largesend.conf' # noqa command-instead-of-shell + ansible.builtin.shell: "{{ __sap_hana_preconfigure_register_ibm_largesend_sysctl_command.stdout }}" + register: __sap_hana_preconfigure_register_ibm_largesend_sysctl_p_output_old + changed_when: false + + - name: Reload kernel parameters from file '/etc/sysctl.d/ibm_largesend.conf' ansible.builtin.command: sysctl -p /etc/sysctl.d/ibm_largesend.conf - register: __sap_hana_preconfigure_register_ibm_largesend_sysctl_p_output + register: __sap_hana_preconfigure_register_ibm_largesend_sysctl_p_output_new + changed_when: __sap_hana_preconfigure_register_ibm_largesend_sysctl_p_output_old.stdout != __sap_hana_preconfigure_register_ibm_largesend_sysctl_p_output_new.stdout - name: Display largesend kernel parameters ansible.builtin.debug: - var: __sap_hana_preconfigure_register_ibm_largesend_sysctl_p_output.stdout_lines + var: __sap_hana_preconfigure_register_ibm_largesend_sysctl_p_output_new.stdout_lines diff --git a/roles/sap_hana_preconfigure/tasks/sapnote/2382421.yml b/roles/sap_hana_preconfigure/tasks/sapnote/2382421.yml index b9f0985d6..823a604f9 100644 --- a/roles/sap_hana_preconfigure/tasks/sapnote/2382421.yml +++ b/roles/sap_hana_preconfigure/tasks/sapnote/2382421.yml @@ -11,7 +11,7 @@ when: sap_hana_preconfigure_config_all | d(true) or sap_hana_preconfigure_2382421 | d(false) block: - - name: Modify entries in file '{{ __sap_hana_preconfigure_etc_sysctl_saphana_conf }}' + - name: Ensure correct entries in file '{{ __sap_hana_preconfigure_etc_sysctl_saphana_conf }}' ansible.builtin.lineinfile: path: "{{ __sap_hana_preconfigure_etc_sysctl_saphana_conf }}" create: yes @@ -67,11 +67,24 @@ line: "net.core.rmem_max={{ __sap_hana_preconfigure_register_sysctl_ipv4_tcp_rmem.stdout.split()[-1] }}" state: present -# Reason for noqa: We unconditionally reload the kernel parameters without first checking the current values - - name: Reload kernel parameters from file '{{ __sap_hana_preconfigure_etc_sysctl_saphana_conf }}' # noqa no-changed-when +# Note: The sole purpose of the following two tasks is to collect the current value(s) of the kernel parameters +# in __sap_hana_preconfigure_etc_sysctl_saphana_conf so that the "Reload kernel parameters from file ..." task +# can correctly report its 'changed' state. See also https://github.com/sap-linuxlab/community.sap_install/issues/752 . + - name: Construct the command for getting all current parameters of file '{{ __sap_hana_preconfigure_etc_sysctl_saphana_conf }}' + ansible.builtin.command: awk 'BEGIN{FS="="; printf ("sysctl ")}{printf ("%s ", $1)}' "{{ __sap_hana_preconfigure_etc_sysctl_saphana_conf }}" + register: __sap_hana_preconfigure_register_saphana_conf_sysctl_command + changed_when: false + + - name: Get all currently active values of the parameters of file '{{ __sap_hana_preconfigure_etc_sysctl_saphana_conf }}' + ansible.builtin.command: "{{ __sap_hana_preconfigure_register_saphana_conf_sysctl_command.stdout }}" + register: __sap_hana_preconfigure_register_saphana_conf_sysctl_p_output_old + changed_when: false + + - name: Reload kernel parameters from file '{{ __sap_hana_preconfigure_etc_sysctl_saphana_conf }}' ansible.builtin.command: sysctl -p "{{ __sap_hana_preconfigure_etc_sysctl_saphana_conf }}" - register: __sap_hana_preconfigure_register_saphana_conf_sysctl_p_output + register: __sap_hana_preconfigure_register_saphana_conf_sysctl_p_output_new + changed_when: __sap_hana_preconfigure_register_saphana_conf_sysctl_p_output_old.stdout != __sap_hana_preconfigure_register_saphana_conf_sysctl_p_output_new.stdout - name: Display kernel parameters for network tuning ansible.builtin.debug: - var: __sap_hana_preconfigure_register_saphana_conf_sysctl_p_output.stdout_lines + var: __sap_hana_preconfigure_register_saphana_conf_sysctl_p_output_new.stdout_lines diff --git a/roles/sap_hana_preconfigure/tasks/sapnote/3024346.yml b/roles/sap_hana_preconfigure/tasks/sapnote/3024346.yml index 9055a84f4..765b93169 100644 --- a/roles/sap_hana_preconfigure/tasks/sapnote/3024346.yml +++ b/roles/sap_hana_preconfigure/tasks/sapnote/3024346.yml @@ -13,7 +13,7 @@ - sap_hana_preconfigure_config_all|d(true) or sap_hana_preconfigure_3024346|d(false) block: - - name: Modify entries in file '{{ __sap_hana_preconfigure_etc_sysctl_netapp_hana_conf }}' + - name: Ensure correct entries in file '{{ __sap_hana_preconfigure_etc_sysctl_netapp_hana_conf }}' ansible.builtin.lineinfile: path: "{{ __sap_hana_preconfigure_etc_sysctl_netapp_hana_conf }}" create: yes @@ -25,14 +25,30 @@ loop_control: loop_var: line_item -# Reason for noqa: We unconditionally reload the kernel parameters without first checking the current values - - name: Reload kernel parameters from file '{{ __sap_hana_preconfigure_etc_sysctl_netapp_hana_conf }}' # noqa no-changed-when +# Note: The sole purpose of the following two tasks is to collect the current value(s) of the kernel parameters +# in __sap_hana_preconfigure_etc_sysctl_netapp_hana_conf so that the "Reload kernel parameters from file ..." task +# can correctly report its 'changed' state. See also https://github.com/sap-linuxlab/community.sap_install/issues/752 . + - name: Construct the command for getting all current parameters of file '{{ __sap_hana_preconfigure_etc_sysctl_netapp_hana_conf }}' + ansible.builtin.command: awk 'BEGIN{FS="="; printf ("sysctl ")}{printf ("%s ", $1)}' "{{ __sap_hana_preconfigure_etc_sysctl_netapp_hana_conf }}" + register: __sap_hana_preconfigure_register_netapp_sysctl_command + changed_when: false + +# Reason for noqa - risky-shell-pipe: when adding 'set -o pipefail', the complete string is attempted to be executed as a single command. +# Also the command after the pipe is not expected to fail. +# Reason for noqa - no-tabs: This is a false positive in ansible-lint 6.22.2, removed in 24.5.0. See https://github.com/ansible/ansible-lint/issues/4020 + - name: Get all currently active values of the parameters of file '{{ __sap_hana_preconfigure_etc_sysctl_netapp_hana_conf }}' # noqa risky-shell-pipe no-tabs + ansible.builtin.shell: "{{ __sap_hana_preconfigure_register_netapp_sysctl_command.stdout }} | sed 's,\t, ,g'" + register: __sap_hana_preconfigure_register_netapp_sysctl_p_output_old + changed_when: false + + - name: Reload kernel parameters from file '{{ __sap_hana_preconfigure_etc_sysctl_netapp_hana_conf }}' ansible.builtin.command: sysctl -p "{{ __sap_hana_preconfigure_etc_sysctl_netapp_hana_conf }}" - register: __sap_hana_preconfigure_register_netapp_sysctl_p_output + register: __sap_hana_preconfigure_register_netapp_sysctl_p_output_new + changed_when: __sap_hana_preconfigure_register_netapp_sysctl_p_output_old.stdout != __sap_hana_preconfigure_register_netapp_sysctl_p_output_new.stdout - name: Display kernel parameters for NetApp NFS ansible.builtin.debug: - var: __sap_hana_preconfigure_register_netapp_sysctl_p_output.stdout_lines + var: __sap_hana_preconfigure_register_netapp_sysctl_p_output_new.stdout_lines - name: Set kernel tunable for NFSv3 as per SAP note 3024346 ansible.builtin.lineinfile: