From 8e25a13ce5e1e2859278d737df6ac6e58ea5be5a Mon Sep 17 00:00:00 2001 From: Bernd Finger Date: Wed, 20 Dec 2023 17:42:29 +0100 Subject: [PATCH 1/6] sap_hana_preconfigure: Add support for Ansible 2.16.1 Solves issue #556 for this role. Signed-off-by: Bernd Finger --- .../tasks/RedHat/assert-installation.yml | 12 ++++++------ .../RedHat/generic/assert-2055470-loop-block.yml | 9 +++++++-- .../RedHat/generic/assert-2382421-loop-block.yml | 9 +++++++-- .../RedHat/generic/assert-3024346-loop-block.yml | 9 +++++++-- .../tasks/RedHat/generic/assert-services.yml | 12 ++++++------ .../tasks/RedHat/generic/assert-tuned.yml | 2 +- .../tasks/RedHat/installation.yml | 2 +- .../tasks/sapnote/assert-2382421.yml | 16 ++++++++-------- 8 files changed, 43 insertions(+), 28 deletions(-) diff --git a/roles/sap_hana_preconfigure/tasks/RedHat/assert-installation.yml b/roles/sap_hana_preconfigure/tasks/RedHat/assert-installation.yml index 02e6bd3e7..4e7ddd803 100644 --- a/roles/sap_hana_preconfigure/tasks/RedHat/assert-installation.yml +++ b/roles/sap_hana_preconfigure/tasks/RedHat/assert-installation.yml @@ -2,7 +2,7 @@ - name: Assert that the system is running a RHEL release which is supported for SAP HANA ansible.builtin.assert: - that: ansible_distribution_version in "{{ sap_hana_preconfigure_supported_rhel_minor_releases }}" + that: ansible_distribution_version in sap_hana_preconfigure_supported_rhel_minor_releases fail_msg: - "FAIL: The RHEL release '{{ ansible_distribution_version }}' may not (yet) be supported for SAP HANA. Please check SAP note 2235581!" - "NOTE: If necessary, adapt role parameter `sap_hana_preconfigure_supported_rhel_minor_releases` accordingly." @@ -12,7 +12,7 @@ - name: Report if the RHEL release is supported for SAP HANA ansible.builtin.assert: - that: ansible_distribution_version in "{{ sap_hana_preconfigure_supported_rhel_minor_releases }}" + that: ansible_distribution_version in sap_hana_preconfigure_supported_rhel_minor_releases fail_msg: - "WARN: The RHEL release '{{ ansible_distribution_version }}' may not (yet) be supported for SAP HANA. Please check SAP note 2235581!" - "NOTE: If necessary, adapt role parameter `sap_hana_preconfigure_supported_rhel_minor_releases` accordingly." @@ -33,7 +33,7 @@ - name: Assert that all required repos are enabled ansible.builtin.assert: - that: "'{{ line_item }}' in __sap_hana_preconfigure_register_enabled_repos_assert.stdout_lines" + that: line_item in __sap_hana_preconfigure_register_enabled_repos_assert.stdout_lines fail_msg: "FAIL: Repository '{{ line_item }}' is not enabled!" success_msg: "PASS: Repository '{{ line_item }}' is enabled." with_items: @@ -54,7 +54,7 @@ - name: Assert that the RHEL release is locked correctly ansible.builtin.assert: - that: "__sap_hana_preconfigure_register_subscription_manager_release_assert.stdout == '{{ ansible_distribution_version }}'" + that: __sap_hana_preconfigure_register_subscription_manager_release_assert.stdout == ansible_distribution_version fail_msg: "FAIL: The RHEL release lock status is '{{ __sap_hana_preconfigure_register_subscription_manager_release_assert.stdout }}' but the expected value is '{{ ansible_distribution_version }}'!" success_msg: "PASS: The RHEL release is correctly locked to '{{ ansible_distribution_version }}'." @@ -69,7 +69,7 @@ - name: Assert that all required packages are installed ansible.builtin.assert: - that: "'{{ line_item }}' in ansible_facts.packages" + that: line_item in ansible_facts.packages fail_msg: "FAIL: Package '{{ line_item }}' is not installed!" success_msg: "PASS: Package '{{ line_item }}' is installed." with_items: @@ -95,7 +95,7 @@ - name: Assert that all required IBM packages are installed ansible.builtin.assert: - that: "'{{ line_item }}' in __sap_hana_preconfigure_register_required_ppc64le_packages_assert.stdout_lines" + that: line_item in __sap_hana_preconfigure_register_required_ppc64le_packages_assert.stdout_lines fail_msg: "FAIL: Package '{{ line_item }}' is not installed!" success_msg: "PASS: Package '{{ line_item }}' is installed." with_items: diff --git a/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-2055470-loop-block.yml b/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-2055470-loop-block.yml index b0729f9fb..99033b7fe 100644 --- a/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-2055470-loop-block.yml +++ b/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-2055470-loop-block.yml @@ -9,9 +9,14 @@ ignore_errors: yes when: __sap_hana_preconfigure_register_stat_sysctl_ibm_largesend_conf_assert.stat.exists +# needed because line_item.value is not evaluated correctly in the that: statement +- name: 2055470 - Set fact for line_item.value + ansible.builtin.set_fact: + __sap_hana_preconfigure_sysctl_value_2055470: "{{ line_item.value }}" + - name: 2055470 - Assert that {{ line_item.name }} is set correctly in /etc/sysctl.d/ibm_largesend.conf ansible.builtin.assert: - that: "__sap_hana_preconfigure_register_sysctl_ibm_largesend_conf_parameter_assert.stdout == '{{ line_item.value }}'" + that: __sap_hana_preconfigure_register_sysctl_ibm_largesend_conf_parameter_assert.stdout == __sap_hana_preconfigure_sysctl_value_2055470 fail_msg: "FAIL: The value of '{{ line_item.name }}' in /etc/sysctl.d/ibm_largesend.conf is '{{ __sap_hana_preconfigure_register_sysctl_ibm_largesend_conf_parameter_assert.stdout }}' but the expected value is 'line_item.value'!" success_msg: "PASS: The value of '{{ line_item.name }}' in /etc/sysctl.d/ibm_largesend.conf is @@ -27,7 +32,7 @@ - name: 2055470 - Assert that {{ line_item.name }} is set correctly as per sysctl ansible.builtin.assert: - that: "__sap_hana_preconfigure_register_sysctl_ibm_parameter_assert.stdout == '{{ line_item.value }}'" + that: __sap_hana_preconfigure_register_sysctl_ibm_parameter_assert.stdout == __sap_hana_preconfigure_sysctl_value_2055470 fail_msg: "FAIL: The current value of '{{ line_item.name }}' as per sysctl is '{{ __sap_hana_preconfigure_register_sysctl_ibm_parameter_assert.stdout }}' but the expected value is '{{ line_item.value }}'!" success_msg: "PASS: The current value of '{{ line_item.name }}' as per sysctl is diff --git a/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-2382421-loop-block.yml b/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-2382421-loop-block.yml index 1e86d0e9f..acc436cac 100644 --- a/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-2382421-loop-block.yml +++ b/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-2382421-loop-block.yml @@ -9,9 +9,14 @@ ignore_errors: yes when: __sap_hana_preconfigure_register_stat_sysctl_saphana_conf_assert.stat.exists +# needed because line_item.value is not evaluated correctly in the that: statement +- name: 2382421 - Set fact for line_item.value + ansible.builtin.set_fact: + __sap_hana_preconfigure_sysctl_value_2382421: "{{ line_item.value }}" + - name: 2382421 - Assert that {{ line_item.name }} is set correctly in {{ __sap_hana_preconfigure_etc_sysctl_saphana_conf }} ansible.builtin.assert: - that: "__sap_hana_preconfigure_register_sysctl_saphana_conf_network_parameter_assert.stdout == '{{ line_item.value }}'" + that: __sap_hana_preconfigure_register_sysctl_saphana_conf_network_parameter_assert.stdout == __sap_hana_preconfigure_sysctl_value_2382421 fail_msg: "FAIL: The value of '{{ line_item.name }}' in {{ __sap_hana_preconfigure_etc_sysctl_saphana_conf }} is '{{ __sap_hana_preconfigure_register_sysctl_saphana_conf_network_parameter_assert.stdout }}' but the expected value is 'line_item.value'!" success_msg: "PASS: The value of '{{ line_item.name }}' in {{ __sap_hana_preconfigure_etc_sysctl_saphana_conf }} is @@ -27,7 +32,7 @@ - name: 2382421 - Assert that {{ line_item.name }} is set correctly as per sysctl ansible.builtin.assert: - that: "__sap_hana_preconfigure_register_sysctl_network_parameter_assert.stdout == '{{ line_item.value }}'" + that: __sap_hana_preconfigure_register_sysctl_network_parameter_assert.stdout == __sap_hana_preconfigure_sysctl_value_2382421 fail_msg: "FAIL: The current value of '{{ line_item.name }}' as per sysctl is '{{ __sap_hana_preconfigure_register_sysctl_network_parameter_assert.stdout }}' but the expected value is '{{ line_item.value }}'!" success_msg: "PASS: The current value of '{{ line_item.name }}' as per sysctl is diff --git a/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-3024346-loop-block.yml b/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-3024346-loop-block.yml index f343a882d..bb1d1dd76 100644 --- a/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-3024346-loop-block.yml +++ b/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-3024346-loop-block.yml @@ -9,9 +9,14 @@ ignore_errors: yes when: __sap_hana_preconfigure_register_etc_sysctl_netapp_hana_conf_assert.stat.exists +# needed because line_item.value is not evaluated correctly in the that: statement +- name: 3024346 - Set fact for line_item.value + ansible.builtin.set_fact: + __sap_hana_preconfigure_sysctl_value_3024346: "{{ line_item.value }}" + - name: 3024346 - Assert that {{ line_item.name }} is set correctly in {{ __sap_hana_preconfigure_etc_sysctl_netapp_hana_conf }} ansible.builtin.assert: - that: "__sap_hana_preconfigure_register_sysctl_netapp_hana_conf_network_parameter_assert.stdout == '{{ line_item.value }}'" + that: __sap_hana_preconfigure_register_sysctl_netapp_hana_conf_network_parameter_assert.stdout == __sap_hana_preconfigure_sysctl_value_3024346 fail_msg: "FAIL: The value of '{{ line_item.name }}' in '{{ __sap_hana_preconfigure_etc_sysctl_saphana_conf }}' is '{{ __sap_hana_preconfigure_register_sysctl_netapp_hana_conf_network_parameter_assert.stdout }}' but the expected value is 'line_item.value'!" success_msg: "PASS: The value of '{{ line_item.name }}' in '{{ __sap_hana_preconfigure_etc_sysctl_saphana_conf }}' is @@ -27,7 +32,7 @@ - name: 3024346 - Assert that {{ line_item.name }} is set correctly as per sysctl ansible.builtin.assert: - that: "__sap_hana_preconfigure_register_sysctl_netapp_hana_network_parameter_assert.stdout == '{{ line_item.value }}'" + that: __sap_hana_preconfigure_register_sysctl_netapp_hana_network_parameter_assert.stdout == __sap_hana_preconfigure_sysctl_value_3024346 fail_msg: "FAIL: The current value of '{{ line_item.name }}' as per sysctl is '{{ __sap_hana_preconfigure_register_sysctl_netapp_hana_network_parameter_assert.stdout }}' but the expected value is '{{ line_item.value }}'!" success_msg: "PASS: The current value of '{{ line_item.name }}' as per sysctl is diff --git a/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-services.yml b/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-services.yml index 55de317c8..5ca268160 100644 --- a/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-services.yml +++ b/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-services.yml @@ -12,8 +12,8 @@ - name: Assert that service {{ __sap_hana_preconfigure_packages_and_services[line_item].svc }} is {{ __sap_hana_preconfigure_packages_and_services[line_item].svc_status }} ansible.builtin.assert: - that: "ansible_facts.services['{{ __sap_hana_preconfigure_packages_and_services[line_item].svc }}.service'].status == - '{{ __sap_hana_preconfigure_packages_and_services[line_item].svc_status }}'" + that: ansible_facts.services['{{ __sap_hana_preconfigure_packages_and_services[line_item].svc }}.service'].status == + __sap_hana_preconfigure_packages_and_services[line_item].svc_status fail_msg: "FAIL: Service '{{ __sap_hana_preconfigure_packages_and_services[line_item].svc }}' is not {{ __sap_hana_preconfigure_packages_and_services[line_item].svc_status }}!" success_msg: "PASS: Service '{{ __sap_hana_preconfigure_packages_and_services[line_item].svc }}' is @@ -24,10 +24,10 @@ {{ __sap_hana_preconfigure_packages_and_services[line_item].svc_state }} or {{ __sap_hana_preconfigure_packages_and_services[line_item].systemd_state }} ansible.builtin.assert: - that: "(ansible_facts.services['{{ __sap_hana_preconfigure_packages_and_services[line_item].svc }}.service'].state == - '{{ __sap_hana_preconfigure_packages_and_services[line_item].svc_state }}' or - ansible_facts.services['{{ __sap_hana_preconfigure_packages_and_services[line_item].svc }}.service'].state == - '{{ __sap_hana_preconfigure_packages_and_services[line_item].systemd_state }}')" + that: (ansible_facts.services['{{ __sap_hana_preconfigure_packages_and_services[line_item].svc }}.service'].state == + __sap_hana_preconfigure_packages_and_services[line_item].svc_state) or + (ansible_facts.services['{{ __sap_hana_preconfigure_packages_and_services[line_item].svc }}.service'].state == + __sap_hana_preconfigure_packages_and_services[line_item].systemd_state) fail_msg: "FAIL: Service '{{ __sap_hana_preconfigure_packages_and_services[line_item].svc }}' is not {{ __sap_hana_preconfigure_packages_and_services[line_item].svc_state }}!" success_msg: "PASS: Service '{{ __sap_hana_preconfigure_packages_and_services[line_item].svc }}' is diff --git a/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-tuned.yml b/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-tuned.yml index 304c029e8..170d2fdf4 100644 --- a/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-tuned.yml +++ b/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-tuned.yml @@ -88,7 +88,7 @@ - name: Assert that tuned profile '{{ sap_hana_preconfigure_tuned_profile }}' is currently active ansible.builtin.assert: - that: "__sap_hana_preconfigure_register_current_tuned_profile_assert.stdout == '{{ sap_hana_preconfigure_tuned_profile }}'" + that: __sap_hana_preconfigure_register_current_tuned_profile_assert.stdout == sap_hana_preconfigure_tuned_profile fail_msg: "FAIL: The tuned profile '{{ sap_hana_preconfigure_tuned_profile }}' is currently not active! Currently active profile: '{{ __sap_hana_preconfigure_register_current_tuned_profile_assert.stdout }}'." success_msg: "PASS: The tuned profile '{{ sap_hana_preconfigure_tuned_profile }}' is currently active." diff --git a/roles/sap_hana_preconfigure/tasks/RedHat/installation.yml b/roles/sap_hana_preconfigure/tasks/RedHat/installation.yml index c3b68c0e6..c93046e30 100644 --- a/roles/sap_hana_preconfigure/tasks/RedHat/installation.yml +++ b/roles/sap_hana_preconfigure/tasks/RedHat/installation.yml @@ -15,7 +15,7 @@ - name: Fail if the system is running a RHEL release which may not be supported for SAP HANA ansible.builtin.assert: - that: ansible_distribution_version in "{{ sap_hana_preconfigure_supported_rhel_minor_releases }}" + that: ansible_distribution_version in sap_hana_preconfigure_supported_rhel_minor_releases fail_msg: - "The RHEL release '{{ ansible_distribution_version }}' may not (yet) be supported for SAP HANA. Please check SAP note 2235581!" - "If necessary, adapt role parameter `sap_hana_preconfigure_supported_rhel_minor_releases` accordingly." diff --git a/roles/sap_hana_preconfigure/tasks/sapnote/assert-2382421.yml b/roles/sap_hana_preconfigure/tasks/sapnote/assert-2382421.yml index d8e7a622f..e847d374e 100644 --- a/roles/sap_hana_preconfigure/tasks/sapnote/assert-2382421.yml +++ b/roles/sap_hana_preconfigure/tasks/sapnote/assert-2382421.yml @@ -65,8 +65,8 @@ - name: 2382421 - Assert that net.core.wmem_max is set correctly in {{ __sap_hana_preconfigure_etc_sysctl_saphana_conf }} ansible.builtin.assert: - that: "__sap_hana_preconfigure_register_sysctl_saphana_conf_wmem_max_assert.stdout == - '{{ __sap_hana_preconfigure_register_sysctl_ipv4_tcp_wmem_assert.stdout.split()[-1] }}'" + that: __sap_hana_preconfigure_register_sysctl_saphana_conf_wmem_max_assert.stdout == + __sap_hana_preconfigure_register_sysctl_ipv4_tcp_wmem_assert.stdout.split()[-1] fail_msg: "FAIL: The value of 'net.core.wmem_max' in {{ __sap_hana_preconfigure_etc_sysctl_saphana_conf }} is '{{ __sap_hana_preconfigure_register_sysctl_saphana_conf_wmem_max_assert.stdout }}' but the expected value is '{{ __sap_hana_preconfigure_register_sysctl_ipv4_tcp_wmem_assert.stdout.split()[-1] }}'!" @@ -83,8 +83,8 @@ - name: 2382421 - Assert that net.core.wmem_max is set correctly as per sysctl ansible.builtin.assert: - that: "'{{ __sap_hana_preconfigure_register_sysctl_ipv4_tcp_wmem_max_assert.stdout.split()[-1] }}' == - '{{ __sap_hana_preconfigure_register_sysctl_ipv4_tcp_wmem_assert.stdout.split()[-1] }}'" + that: __sap_hana_preconfigure_register_sysctl_ipv4_tcp_wmem_max_assert.stdout.split()[-1] == + __sap_hana_preconfigure_register_sysctl_ipv4_tcp_wmem_assert.stdout.split()[-1] fail_msg: "FAIL: The current value of 'net.core.wmem_max as per sysctl is '{{ __sap_hana_preconfigure_register_sysctl_ipv4_tcp_wmem_max_assert.stdout.split()[-1] }}' but the expected value is '{{ __sap_hana_preconfigure_register_sysctl_ipv4_tcp_wmem_assert.stdout.split()[-1] }}'!" @@ -111,8 +111,8 @@ - name: 2382421 - Assert that net.core.rmem_max is set correctly in {{ __sap_hana_preconfigure_etc_sysctl_saphana_conf }} ansible.builtin.assert: - that: "__sap_hana_preconfigure_register_sysctl_saphana_conf_rmem_max_assert.stdout == - '{{ __sap_hana_preconfigure_register_sysctl_ipv4_tcp_rmem_assert.stdout.split()[-1] }}'" + that: __sap_hana_preconfigure_register_sysctl_saphana_conf_rmem_max_assert.stdout == + __sap_hana_preconfigure_register_sysctl_ipv4_tcp_rmem_assert.stdout.split()[-1] fail_msg: "FAIL: The value of 'net.core.rmem_max' in {{ __sap_hana_preconfigure_etc_sysctl_saphana_conf }} is '{{ __sap_hana_preconfigure_register_sysctl_saphana_conf_rmem_max_assert.stdout }}' but the expected value is '{{ __sap_hana_preconfigure_register_sysctl_ipv4_tcp_rmem_assert.stdout.split()[-1] }}'!" @@ -129,8 +129,8 @@ - name: 2382421 - Assert that net.core.rmem_max is set correctly as per sysctl ansible.builtin.assert: - that: "'{{ __sap_hana_preconfigure_register_sysctl_ipv4_tcp_rmem_max_assert.stdout.split()[-1] }}' == - '{{ __sap_hana_preconfigure_register_sysctl_ipv4_tcp_rmem_assert.stdout.split()[-1] }}'" + that: __sap_hana_preconfigure_register_sysctl_ipv4_tcp_rmem_max_assert.stdout.split()[-1] == + __sap_hana_preconfigure_register_sysctl_ipv4_tcp_rmem_assert.stdout.split()[-1] fail_msg: "FAIL: The current value of 'net.core.rmem_max as per sysctl is '{{ __sap_hana_preconfigure_register_sysctl_ipv4_tcp_rmem_max_assert.stdout.split()[-1] }}' but the expected value is '{{ __sap_hana_preconfigure_register_sysctl_ipv4_tcp_rmem_assert.stdout.split()[-1] }}'!" From 42bfd08f8aa8a10e9c9f9634d44542c5e80c9f3a Mon Sep 17 00:00:00 2001 From: Bernd Finger Date: Thu, 21 Dec 2023 10:06:06 +0100 Subject: [PATCH 2/6] sap_hana_preconfigure: remove more double quotes from that: statements Signed-off-by: Bernd Finger --- .../tasks/RedHat/generic/assert-coredumps.yml | 4 ++-- .../tasks/RedHat/generic/assert-ksm.yml | 4 ++-- .../tasks/RedHat/generic/assert-tuned.yml | 8 ++++---- .../tasks/SLES/assert-configuration.yml | 2 +- .../tasks/sapnote/assert-2009879_7.yml | 8 ++++---- .../tasks/sapnote/assert-3024346.yml | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-coredumps.yml b/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-coredumps.yml index 99b25667f..572ad8d54 100644 --- a/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-coredumps.yml +++ b/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-coredumps.yml @@ -29,7 +29,7 @@ - name: Assert that the hard limit of core file creation is 0 for all users ansible.builtin.assert: - that: "__sap_hana_preconfigure_register_limits_sap_conf_core_hard_assert.stdout == '0'" + that: __sap_hana_preconfigure_register_limits_sap_conf_core_hard_assert.stdout == '0' fail_msg: "FAIL: The hard limit of core file creation for all users in /etc/security/limits.d/99-sap.conf is '{{ __sap_hana_preconfigure_register_limits_sap_conf_core_hard_assert.stdout }}' but the expected value is 0!" success_msg: "PASS: The hard limit of core file creation for all users in /etc/security/limits.d/99-sap.conf is @@ -46,7 +46,7 @@ - name: Assert that the soft limit of core file creation is 0 for all users ansible.builtin.assert: - that: "__sap_hana_preconfigure_register_limits_sap_conf_core_soft_assert.stdout == '0'" + that: __sap_hana_preconfigure_register_limits_sap_conf_core_soft_assert.stdout == '0' fail_msg: "FAIL: The soft limit of core file creation for all users in /etc/security/limits.d/99-sap.conf is '{{ __sap_hana_preconfigure_register_limits_sap_conf_core_soft_assert.stdout }}' but the expected value is 0!" success_msg: "PASS: The soft limit of core file creation for all users in /etc/security/limits.d/99-sap.conf is diff --git a/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-ksm.yml b/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-ksm.yml index 383f58c3b..ef35913cc 100644 --- a/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-ksm.yml +++ b/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-ksm.yml @@ -22,7 +22,7 @@ - name: Assert that the mode of file /etc/init.d/boot.local is 0755 ansible.builtin.assert: - that: "__sap_hana_preconfigure_register_stat_boot_local_ksm_assert.stat.mode == '0755'" + that: __sap_hana_preconfigure_register_stat_boot_local_ksm_assert.stat.mode == '0755' fail_msg: "FAIL: File /etc/init.d/boot.local has mode '{{ __sap_hana_preconfigure_register_stat_boot_local_ksm_assert.stat.mode }}' but the expected mode is '0755'!" success_msg: "PASS: File /etc/init.d/boot.local has mode 0755." @@ -52,7 +52,7 @@ - name: Assert that ksm is currently disabled ansible.builtin.assert: - that: "__sap_hana_preconfigure_register_ksm_active_assert.stdout == '0'" + that: __sap_hana_preconfigure_register_ksm_active_assert.stdout == '0' fail_msg: "FAIL: KSM is currently enabled but it needs to be disabled!" success_msg: "PASS: KSM is disabled currently." ignore_errors: "{{ sap_hana_preconfigure_assert_ignore_errors | d(false) }}" diff --git a/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-tuned.yml b/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-tuned.yml index 170d2fdf4..29cccaff0 100644 --- a/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-tuned.yml +++ b/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-tuned.yml @@ -17,7 +17,7 @@ - name: "Assert that tuned is enabled - use_tuned: yes" ansible.builtin.assert: - that: "ansible_facts.services['tuned.service']['status'] == 'enabled'" + that: ansible_facts.services['tuned.service']['status'] == 'enabled' fail_msg: "FAIL: Service 'tuned' is not enabled!" success_msg: "PASS: Service 'tuned' is enabled." ignore_errors: "{{ sap_hana_preconfigure_assert_ignore_errors | d(false) }}" @@ -27,7 +27,7 @@ - name: "Assert that tuned is active - use_tuned: yes" ansible.builtin.assert: - that: "ansible_facts.services['tuned.service']['state'] == 'running'" + that: ansible_facts.services['tuned.service']['state'] == 'running' fail_msg: "FAIL: Service 'tuned' is not active!" success_msg: "PASS: Service 'tuned' is active." ignore_errors: "{{ sap_hana_preconfigure_assert_ignore_errors | d(false) }}" @@ -44,7 +44,7 @@ - name: "Assert that tuned is disabled - use_tuned: no" ansible.builtin.assert: - that: "ansible_facts.services['tuned.service']['status'] == 'disabled'" + that: ansible_facts.services['tuned.service']['status'] == 'disabled' fail_msg: "FAIL: Service 'tuned' is not disabled!" success_msg: "PASS: Service 'tuned' is disabled." ignore_errors: "{{ sap_hana_preconfigure_assert_ignore_errors | d(false) }}" @@ -54,7 +54,7 @@ - name: "Assert that tuned is inactive - use_tuned: no" ansible.builtin.assert: - that: "ansible_facts.services['tuned.service']['state'] == 'inactive'" + that: ansible_facts.services['tuned.service']['state'] == 'inactive' fail_msg: "FAIL: Service 'tuned' is not inactive!" success_msg: "PASS: Service 'tuned' is inactive." ignore_errors: "{{ sap_hana_preconfigure_assert_ignore_errors | d(false) }}" diff --git a/roles/sap_hana_preconfigure/tasks/SLES/assert-configuration.yml b/roles/sap_hana_preconfigure/tasks/SLES/assert-configuration.yml index 34fd6f217..3db7a075c 100644 --- a/roles/sap_hana_preconfigure/tasks/SLES/assert-configuration.yml +++ b/roles/sap_hana_preconfigure/tasks/SLES/assert-configuration.yml @@ -23,7 +23,7 @@ - name: Assert that saptune_check executed correctly ansible.builtin.assert: - that: "__sap_hana_preconfigure_register_saptune_check.rc == 0" + that: __sap_hana_preconfigure_register_saptune_check is success fail_msg: "FAIL: the command saptune_check fails" success_msg: "PASS: the command saptune_check executes as expected" diff --git a/roles/sap_hana_preconfigure/tasks/sapnote/assert-2009879_7.yml b/roles/sap_hana_preconfigure/tasks/sapnote/assert-2009879_7.yml index cef71a27e..f6176b580 100644 --- a/roles/sap_hana_preconfigure/tasks/sapnote/assert-2009879_7.yml +++ b/roles/sap_hana_preconfigure/tasks/sapnote/assert-2009879_7.yml @@ -49,7 +49,7 @@ - name: RHEL 7.2 - Assert that file /usr/lib64/libssl.so.1.0.1 is a link to /usr/lib64/libssl.so.1.0.1e ansible.builtin.assert: - that: "__sap_hana_preconfigure_register_stat_libssl_rhel_72_assert.stat.lnk_target == '/usr/lib64/libssl.so.1.0.1e'" + that: __sap_hana_preconfigure_register_stat_libssl_rhel_72_assert.stat.lnk_target == '/usr/lib64/libssl.so.1.0.1e' fail_msg: "FAIL: File /usr/lib64/libssl.so.1.0.1 is not a link to /usr/lib64/libssl.so.1.0.1e!" success_msg: "PASS: File /usr/lib64/libssl.so.1.0.1 is a link to /usr/lib64/libssl.so.1.0.1e." ignore_errors: "{{ sap_hana_preconfigure_assert_ignore_errors | d(false) }}" @@ -77,7 +77,7 @@ - name: RHEL 7.2 - Assert that file /usr/lib64/libcrypto.so.1.0.1 is a link to /usr/lib64/libcrypto.so.1.0.1e ansible.builtin.assert: - that: "__sap_hana_preconfigure_register_stat_libcrypto_rhel_72_assert.stat.lnk_target == '/usr/lib64/libcrypto.so.1.0.1e'" + that: __sap_hana_preconfigure_register_stat_libcrypto_rhel_72_assert.stat.lnk_target == '/usr/lib64/libcrypto.so.1.0.1e' fail_msg: "FAIL: File /usr/lib64/libcrypto.so.1.0.1 is not a link to /usr/lib64/libcrypto.so.1.0.1e!" success_msg: "PASS: File /usr/lib64/libcrypto.so.1.0.1 is a link to /usr/lib64/libcrypto.so.1.0.1e." ignore_errors: "{{ sap_hana_preconfigure_assert_ignore_errors | d(false) }}" @@ -109,7 +109,7 @@ - name: Assert that file /usr/lib64/libssl.so.1.0.1 is a link to /usr/lib64/libssl.so.10 ansible.builtin.assert: - that: "__sap_hana_preconfigure_register_stat_libssl_rhel_7_assert.stat.lnk_target == '/usr/lib64/libssl.so.10'" + that: __sap_hana_preconfigure_register_stat_libssl_rhel_7_assert.stat.lnk_target == '/usr/lib64/libssl.so.10' fail_msg: "FAIL: File /usr/lib64/libssl.so.1.0.1 is not a link to /usr/lib64/libssl.so.10!" success_msg: "PASS: File /usr/lib64/libssl.so.1.0.1 is a link to /usr/lib64/libssl.so.10." ignore_errors: "{{ sap_hana_preconfigure_assert_ignore_errors | d(false) }}" @@ -137,7 +137,7 @@ - name: Assert that file /usr/lib64/libcrypto.so.1.0.1 is a link to /usr/lib64/libcrypto.so.10 ansible.builtin.assert: - that: "__sap_hana_preconfigure_register_stat_libcrypto_rhel_7_assert.stat.lnk_target == '/usr/lib64/libcrypto.so.10'" + that: __sap_hana_preconfigure_register_stat_libcrypto_rhel_7_assert.stat.lnk_target == '/usr/lib64/libcrypto.so.10' fail_msg: "FAIL: File /usr/lib64/libcrypto.so.1.0.1 is not a link to /usr/lib64/libcrypto.so.10!" success_msg: "PASS: File /usr/lib64/libcrypto.so.1.0.1 is a link to /usr/lib64/libcrypto.so.10." ignore_errors: "{{ sap_hana_preconfigure_assert_ignore_errors | d(false) }}" diff --git a/roles/sap_hana_preconfigure/tasks/sapnote/assert-3024346.yml b/roles/sap_hana_preconfigure/tasks/sapnote/assert-3024346.yml index d44cfd7c4..8910a1dd0 100644 --- a/roles/sap_hana_preconfigure/tasks/sapnote/assert-3024346.yml +++ b/roles/sap_hana_preconfigure/tasks/sapnote/assert-3024346.yml @@ -80,7 +80,7 @@ - name: Assert that 'options sunrpc tcp_max_slot_table_entries' is set correctly in /etc/modprobe.d/sunrpc.conf ansible.builtin.assert: - that: "__sap_hana_preconfigure_register_tcp_max_slot_table_entries_assert.stdout == '128'" + that: __sap_hana_preconfigure_register_tcp_max_slot_table_entries_assert.stdout == '128' fail_msg: "FAIL: The value of 'options sunrpc tcp_max_slot_table_entries' in '/etc/modprobe.d/sunrpc.conf' is '{{ __sap_hana_preconfigure_register_tcp_max_slot_table_entries_assert.stdout }}' but the expected value is '128'!" success_msg: "PASS: The value of 'options sunrpc tcp_max_slot_table_entries' in '/etc/modprobe.d/sunrpc.conf' is From 098010d02973975b9fcc5e00a671a78d51e1923e Mon Sep 17 00:00:00 2001 From: Bernd Finger Date: Thu, 21 Dec 2023 10:25:22 +0100 Subject: [PATCH 3/6] sap_hana_preconfigure: remove nested double braces from that: statements Signed-off-by: Bernd Finger --- .../tasks/RedHat/generic/assert-services.yml | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-services.yml b/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-services.yml index 5ca268160..e419c48f2 100644 --- a/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-services.yml +++ b/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-services.yml @@ -9,25 +9,30 @@ ansible.builtin.debug: msg: "INFO: Package '{{ __sap_hana_preconfigure_packages_and_services[line_item].pkg }}' is installed." + - name: Define a new variable for the assertion of the service status + ansible.builtin.set_fact: + __sap_hana_preconfigure_service_item_status: ansible_facts.services['{{ __sap_hana_preconfigure_packages_and_services[line_item].svc }}.service'].status + - name: Assert that service {{ __sap_hana_preconfigure_packages_and_services[line_item].svc }} is {{ __sap_hana_preconfigure_packages_and_services[line_item].svc_status }} ansible.builtin.assert: - that: ansible_facts.services['{{ __sap_hana_preconfigure_packages_and_services[line_item].svc }}.service'].status == - __sap_hana_preconfigure_packages_and_services[line_item].svc_status + that: __sap_hana_preconfigure_service_item_status == __sap_hana_preconfigure_packages_and_services[line_item].svc_status fail_msg: "FAIL: Service '{{ __sap_hana_preconfigure_packages_and_services[line_item].svc }}' is not {{ __sap_hana_preconfigure_packages_and_services[line_item].svc_status }}!" success_msg: "PASS: Service '{{ __sap_hana_preconfigure_packages_and_services[line_item].svc }}' is {{ __sap_hana_preconfigure_packages_and_services[line_item].svc_status }}." ignore_errors: "{{ sap_hana_preconfigure_assert_ignore_errors | d(false) }}" + - name: Define a new variable for the assertion of the service state + ansible.builtin.set_fact: + __sap_hana_preconfigure_service_item_state: ansible_facts.services['{{ __sap_hana_preconfigure_packages_and_services[line_item].svc }}.service'].state + - name: Assert that service {{ __sap_hana_preconfigure_packages_and_services[line_item].svc }} is {{ __sap_hana_preconfigure_packages_and_services[line_item].svc_state }} or {{ __sap_hana_preconfigure_packages_and_services[line_item].systemd_state }} ansible.builtin.assert: - that: (ansible_facts.services['{{ __sap_hana_preconfigure_packages_and_services[line_item].svc }}.service'].state == - __sap_hana_preconfigure_packages_and_services[line_item].svc_state) or - (ansible_facts.services['{{ __sap_hana_preconfigure_packages_and_services[line_item].svc }}.service'].state == - __sap_hana_preconfigure_packages_and_services[line_item].systemd_state) + that: (__sap_hana_preconfigure_service_item_state == __sap_hana_preconfigure_packages_and_services[line_item].svc_state) or + (__sap_hana_preconfigure_service_item_state == __sap_hana_preconfigure_packages_and_services[line_item].systemd_state) fail_msg: "FAIL: Service '{{ __sap_hana_preconfigure_packages_and_services[line_item].svc }}' is not {{ __sap_hana_preconfigure_packages_and_services[line_item].svc_state }}!" success_msg: "PASS: Service '{{ __sap_hana_preconfigure_packages_and_services[line_item].svc }}' is From 5afc8c305c5ae39e68430c63120fc9ef6d673d8c Mon Sep 17 00:00:00 2001 From: Bernd Finger Date: Thu, 21 Dec 2023 10:31:57 +0100 Subject: [PATCH 4/6] sap_hana_preconfigure: add parentheses to some that: statements Signed-off-by: Bernd Finger --- .../tasks/RedHat/generic/assert-2777782-01-loop-block.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-2777782-01-loop-block.yml b/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-2777782-01-loop-block.yml index 5a7f625ef..6dc476aaf 100644 --- a/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-2777782-01-loop-block.yml +++ b/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-2777782-01-loop-block.yml @@ -21,7 +21,7 @@ - name: Assert that there is an entry for '{{ line_item }}' in the SELinux configuration database ansible.builtin.assert: - that: __sap_hana_preconfigure_register_semanage_fcontext_hana.stdout | int != 0 + that: (__sap_hana_preconfigure_register_semanage_fcontext_hana.stdout | int) != 0 fail_msg: "FAIL: There is no entry for '{{ line_item }}' in the SELinux configuration database!" success_msg: "PASS: There is an entry for '{{ line_item }}' in the SELinux configuration database." ignore_errors: "{{ sap_hana_preconfigure_assert_ignore_errors | d(false) }}" @@ -35,7 +35,7 @@ - name: Assert that all files in '{{ line_item }}' and below have the 'usr_t' file context ansible.builtin.assert: - that: __sap_hana_preconfigure_register_ls_z_hana.stdout | int == 0 + that: (__sap_hana_preconfigure_register_ls_z_hana.stdout | int) == 0 fail_msg: "FAIL: There is at least one file in '{{ line_item }}' or below without the 'usr_t' file context!" success_msg: "PASS: All files in '{{ line_item }}' and below have the 'usr_t' file context." ignore_errors: "{{ sap_hana_preconfigure_assert_ignore_errors | d(false) }}" From e3e3073aa58814a631406d790d258d11a2a7bb58 Mon Sep 17 00:00:00 2001 From: Bernd Finger Date: Thu, 21 Dec 2023 20:10:57 +0100 Subject: [PATCH 5/6] sap_hana_preconfigure: fix wrong variable substitution inside assert-services.yml Signed-off-by: Bernd Finger --- .../tasks/RedHat/generic/assert-abrt-ccpp.yml | 9 ++- .../tasks/RedHat/generic/assert-abrtd.yml | 9 ++- .../generic/assert-auto-numa-balancing.yml | 9 ++- .../tasks/RedHat/generic/assert-firewalld.yml | 9 ++- .../tasks/RedHat/generic/assert-kdump.yml | 9 ++- .../tasks/RedHat/generic/assert-services.yml | 58 ++++++++----------- 6 files changed, 65 insertions(+), 38 deletions(-) diff --git a/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-abrt-ccpp.yml b/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-abrt-ccpp.yml index 4205365a2..fc96e8365 100644 --- a/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-abrt-ccpp.yml +++ b/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-abrt-ccpp.yml @@ -3,4 +3,11 @@ - name: Assert that service abrt-ccpp is disabled, and inactive or stopped ansible.builtin.include_tasks: assert-services.yml vars: - line_item: abrt-ccpp + __sap_hana_preconfigure_service_status: "{{ ansible_facts.services['abrt-ccpp.service'].status }}" + __sap_hana_preconfigure_service_state: "{{ ansible_facts.services['abrt-ccpp.service'].state }}" + __sap_hana_preconfigure_packages_and_services_pkg: "{{ __sap_hana_preconfigure_packages_and_services['abrt-ccpp']['pkg'] }}" + __sap_hana_preconfigure_packages_and_services_svc: "{{ __sap_hana_preconfigure_packages_and_services['abrt-ccpp']['svc'] }}" + __sap_hana_preconfigure_packages_and_services_svc_status: "{{ __sap_hana_preconfigure_packages_and_services['abrt-ccpp']['svc_status'] }}" + __sap_hana_preconfigure_packages_and_services_svc_state: "{{ __sap_hana_preconfigure_packages_and_services['abrt-ccpp']['svc_state'] }}" + __sap_hana_preconfigure_packages_and_services_systemd_enabled: "{{ __sap_hana_preconfigure_packages_and_services['abrt-ccpp']['systemd_enabled'] }}" + __sap_hana_preconfigure_packages_and_services_systemd_state: "{{ __sap_hana_preconfigure_packages_and_services['abrt-ccpp']['systemd_state'] }}" diff --git a/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-abrtd.yml b/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-abrtd.yml index 54a1cf887..36a63798a 100644 --- a/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-abrtd.yml +++ b/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-abrtd.yml @@ -3,4 +3,11 @@ - name: Assert that service abrtd is disabled, and inactive or stopped ansible.builtin.include_tasks: assert-services.yml vars: - line_item: abrtd + __sap_hana_preconfigure_service_status: "{{ ansible_facts.services['abrtd.service'].status }}" + __sap_hana_preconfigure_service_state: "{{ ansible_facts.services['abrtd.service'].state }}" + __sap_hana_preconfigure_packages_and_services_pkg: "{{ __sap_hana_preconfigure_packages_and_services['abrtd']['pkg'] }}" + __sap_hana_preconfigure_packages_and_services_svc: "{{ __sap_hana_preconfigure_packages_and_services['abrtd']['svc'] }}" + __sap_hana_preconfigure_packages_and_services_svc_status: "{{ __sap_hana_preconfigure_packages_and_services['abrtd']['svc_status'] }}" + __sap_hana_preconfigure_packages_and_services_svc_state: "{{ __sap_hana_preconfigure_packages_and_services['abrtd']['svc_state'] }}" + __sap_hana_preconfigure_packages_and_services_systemd_enabled: "{{ __sap_hana_preconfigure_packages_and_services['abrtd']['systemd_enabled'] }}" + __sap_hana_preconfigure_packages_and_services_systemd_state: "{{ __sap_hana_preconfigure_packages_and_services['abrtd']['systemd_state'] }}" diff --git a/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-auto-numa-balancing.yml b/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-auto-numa-balancing.yml index f75cbea44..94628b8ae 100644 --- a/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-auto-numa-balancing.yml +++ b/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-auto-numa-balancing.yml @@ -4,7 +4,14 @@ - name: Assert that service numad is disabled, and inactive or stopped, if tuned is not to be used ansible.builtin.include_tasks: assert-services.yml vars: - line_item: numad + __sap_hana_preconfigure_service_status: "{{ ansible_facts.services['numad.service'].status }}" + __sap_hana_preconfigure_service_state: "{{ ansible_facts.services['numad.service'].state }}" + __sap_hana_preconfigure_packages_and_services_pkg: "{{ __sap_hana_preconfigure_packages_and_services['numad']['pkg'] }}" + __sap_hana_preconfigure_packages_and_services_svc: "{{ __sap_hana_preconfigure_packages_and_services['numad']['svc'] }}" + __sap_hana_preconfigure_packages_and_services_svc_status: "{{ __sap_hana_preconfigure_packages_and_services['numad']['svc_status'] }}" + __sap_hana_preconfigure_packages_and_services_svc_state: "{{ __sap_hana_preconfigure_packages_and_services['numad']['svc_state'] }}" + __sap_hana_preconfigure_packages_and_services_systemd_enabled: "{{ __sap_hana_preconfigure_packages_and_services['numad']['systemd_enabled'] }}" + __sap_hana_preconfigure_packages_and_services_systemd_state: "{{ __sap_hana_preconfigure_packages_and_services['numad']['systemd_state'] }}" when: not sap_hana_preconfigure_use_tuned or sap_hana_preconfigure_assert_all_config|d(false) diff --git a/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-firewalld.yml b/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-firewalld.yml index 576b70e56..5cb157679 100644 --- a/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-firewalld.yml +++ b/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-firewalld.yml @@ -3,4 +3,11 @@ - name: Assert that service firewalld is disabled, and inactive or stopped ansible.builtin.include_tasks: assert-services.yml vars: - line_item: firewalld + __sap_hana_preconfigure_service_status: "{{ ansible_facts.services['firewalld.service'].status }}" + __sap_hana_preconfigure_service_state: "{{ ansible_facts.services['firewalld.service'].state }}" + __sap_hana_preconfigure_packages_and_services_pkg: "{{ __sap_hana_preconfigure_packages_and_services['firewalld']['pkg'] }}" + __sap_hana_preconfigure_packages_and_services_svc: "{{ __sap_hana_preconfigure_packages_and_services['firewalld']['svc'] }}" + __sap_hana_preconfigure_packages_and_services_svc_status: "{{ __sap_hana_preconfigure_packages_and_services['firewalld']['svc_status'] }}" + __sap_hana_preconfigure_packages_and_services_svc_state: "{{ __sap_hana_preconfigure_packages_and_services['firewalld']['svc_state'] }}" + __sap_hana_preconfigure_packages_and_services_systemd_enabled: "{{ __sap_hana_preconfigure_packages_and_services['firewalld']['systemd_enabled'] }}" + __sap_hana_preconfigure_packages_and_services_systemd_state: "{{ __sap_hana_preconfigure_packages_and_services['firewalld']['systemd_state'] }}" diff --git a/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-kdump.yml b/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-kdump.yml index 66fe0b1de..de5c370fc 100644 --- a/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-kdump.yml +++ b/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-kdump.yml @@ -3,4 +3,11 @@ - name: Assert that service kdump is disabled, and inactive or stopped ansible.builtin.include_tasks: assert-services.yml vars: - line_item: kdump + __sap_hana_preconfigure_service_status: "{{ ansible_facts.services['kdump.service'].status }}" + __sap_hana_preconfigure_service_state: "{{ ansible_facts.services['kdump.service'].state }}" + __sap_hana_preconfigure_packages_and_services_pkg: "{{ __sap_hana_preconfigure_packages_and_services['kdump']['pkg'] }}" + __sap_hana_preconfigure_packages_and_services_svc: "{{ __sap_hana_preconfigure_packages_and_services['kdump']['svc'] }}" + __sap_hana_preconfigure_packages_and_services_svc_status: "{{ __sap_hana_preconfigure_packages_and_services['kdump']['svc_status'] }}" + __sap_hana_preconfigure_packages_and_services_svc_state: "{{ __sap_hana_preconfigure_packages_and_services['kdump']['svc_state'] }}" + __sap_hana_preconfigure_packages_and_services_systemd_enabled: "{{ __sap_hana_preconfigure_packages_and_services['kdump']['systemd_enabled'] }}" + __sap_hana_preconfigure_packages_and_services_systemd_state: "{{ __sap_hana_preconfigure_packages_and_services['kdump']['systemd_state'] }}" diff --git a/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-services.yml b/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-services.yml index e419c48f2..cd01228d3 100644 --- a/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-services.yml +++ b/roles/sap_hana_preconfigure/tasks/RedHat/generic/assert-services.yml @@ -1,46 +1,38 @@ --- -- name: Assert that service {{ __sap_hana_preconfigure_packages_and_services[line_item].svc }} is disabled - if package {{ __sap_hana_preconfigure_packages_and_services[line_item].pkg }} is installed - when: "__sap_hana_preconfigure_packages_and_services[line_item].pkg in ansible_facts.packages" +- name: Assert that service {{ __sap_hana_preconfigure_packages_and_services_svc }} is disabled + if package {{ __sap_hana_preconfigure_packages_and_services_pkg }} is installed + when: "__sap_hana_preconfigure_packages_and_services_pkg in ansible_facts.packages" block: - - name: "Report that package {{ __sap_hana_preconfigure_packages_and_services[line_item].pkg }} is installed" + - name: "Report that package {{ __sap_hana_preconfigure_packages_and_services_pkg }} is installed" ansible.builtin.debug: - msg: "INFO: Package '{{ __sap_hana_preconfigure_packages_and_services[line_item].pkg }}' is installed." + msg: "INFO: Package '{{ __sap_hana_preconfigure_packages_and_services_pkg }}' is installed." - - name: Define a new variable for the assertion of the service status - ansible.builtin.set_fact: - __sap_hana_preconfigure_service_item_status: ansible_facts.services['{{ __sap_hana_preconfigure_packages_and_services[line_item].svc }}.service'].status - - - name: Assert that service {{ __sap_hana_preconfigure_packages_and_services[line_item].svc }} is - {{ __sap_hana_preconfigure_packages_and_services[line_item].svc_status }} + - name: Assert that service {{ __sap_hana_preconfigure_packages_and_services_svc }} is + {{ __sap_hana_preconfigure_packages_and_services_svc_status }} ansible.builtin.assert: - that: __sap_hana_preconfigure_service_item_status == __sap_hana_preconfigure_packages_and_services[line_item].svc_status - fail_msg: "FAIL: Service '{{ __sap_hana_preconfigure_packages_and_services[line_item].svc }}' is not - {{ __sap_hana_preconfigure_packages_and_services[line_item].svc_status }}!" - success_msg: "PASS: Service '{{ __sap_hana_preconfigure_packages_and_services[line_item].svc }}' is - {{ __sap_hana_preconfigure_packages_and_services[line_item].svc_status }}." + that: __sap_hana_preconfigure_service_status == __sap_hana_preconfigure_packages_and_services_svc_status + fail_msg: "FAIL: Service '{{ __sap_hana_preconfigure_packages_and_services_svc }}' is not + {{ __sap_hana_preconfigure_packages_and_services_svc_status }}!" + success_msg: "PASS: Service '{{ __sap_hana_preconfigure_packages_and_services_svc }}' is + {{ __sap_hana_preconfigure_packages_and_services_svc_status }}." ignore_errors: "{{ sap_hana_preconfigure_assert_ignore_errors | d(false) }}" - - name: Define a new variable for the assertion of the service state - ansible.builtin.set_fact: - __sap_hana_preconfigure_service_item_state: ansible_facts.services['{{ __sap_hana_preconfigure_packages_and_services[line_item].svc }}.service'].state - - - name: Assert that service {{ __sap_hana_preconfigure_packages_and_services[line_item].svc }} is - {{ __sap_hana_preconfigure_packages_and_services[line_item].svc_state }} or - {{ __sap_hana_preconfigure_packages_and_services[line_item].systemd_state }} + - name: Assert that service {{ __sap_hana_preconfigure_packages_and_services_svc }} is + {{ __sap_hana_preconfigure_packages_and_services_svc_state }} or + {{ __sap_hana_preconfigure_packages_and_services_systemd_state }} ansible.builtin.assert: - that: (__sap_hana_preconfigure_service_item_state == __sap_hana_preconfigure_packages_and_services[line_item].svc_state) or - (__sap_hana_preconfigure_service_item_state == __sap_hana_preconfigure_packages_and_services[line_item].systemd_state) - fail_msg: "FAIL: Service '{{ __sap_hana_preconfigure_packages_and_services[line_item].svc }}' is not - {{ __sap_hana_preconfigure_packages_and_services[line_item].svc_state }}!" - success_msg: "PASS: Service '{{ __sap_hana_preconfigure_packages_and_services[line_item].svc }}' is - {{ __sap_hana_preconfigure_packages_and_services[line_item].svc_state }} or - {{ __sap_hana_preconfigure_packages_and_services[line_item].systemd_state }}." + that: (__sap_hana_preconfigure_service_state == __sap_hana_preconfigure_packages_and_services_svc_state) or + (__sap_hana_preconfigure_service_state == __sap_hana_preconfigure_packages_and_services_systemd_state) + fail_msg: "FAIL: Service '{{ __sap_hana_preconfigure_packages_and_services_svc }}' is not + {{ __sap_hana_preconfigure_packages_and_services_svc_state }}!" + success_msg: "PASS: Service '{{ __sap_hana_preconfigure_packages_and_services_svc }}' is + {{ __sap_hana_preconfigure_packages_and_services_svc_state }} or + {{ __sap_hana_preconfigure_packages_and_services_systemd_state }}." ignore_errors: "{{ sap_hana_preconfigure_assert_ignore_errors | d(false) }}" -- name: "Report that package {{ __sap_hana_preconfigure_packages_and_services[line_item].pkg }} is not installed" +- name: "Report that package {{ __sap_hana_preconfigure_packages_and_services_pkg }} is not installed" ansible.builtin.debug: - msg: "PASS: Package '{{ __sap_hana_preconfigure_packages_and_services[line_item].pkg }}' is not installed." - when: "__sap_hana_preconfigure_packages_and_services[line_item].pkg not in ansible_facts.packages" + msg: "PASS: Package '{{ __sap_hana_preconfigure_packages_and_services_pkg }}' is not installed." + when: "__sap_hana_preconfigure_packages_and_services_pkg not in ansible_facts.packages" From 17bd6f214f8304d6249e680e816ad301b84a9b9b Mon Sep 17 00:00:00 2001 From: berndfinger <49749572+berndfinger@users.noreply.github.com> Date: Wed, 3 Jan 2024 11:40:01 +0100 Subject: [PATCH 6/6] revert " is success" to ".rc == 0" --- roles/sap_hana_preconfigure/tasks/SLES/assert-configuration.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/sap_hana_preconfigure/tasks/SLES/assert-configuration.yml b/roles/sap_hana_preconfigure/tasks/SLES/assert-configuration.yml index 3db7a075c..3cd422126 100644 --- a/roles/sap_hana_preconfigure/tasks/SLES/assert-configuration.yml +++ b/roles/sap_hana_preconfigure/tasks/SLES/assert-configuration.yml @@ -23,7 +23,7 @@ - name: Assert that saptune_check executed correctly ansible.builtin.assert: - that: __sap_hana_preconfigure_register_saptune_check is success + that: __sap_hana_preconfigure_register_saptune_check.rc == 0 fail_msg: "FAIL: the command saptune_check fails" success_msg: "PASS: the command saptune_check executes as expected"