From adda76877a1c567bd030b095171d88d2692eab5f Mon Sep 17 00:00:00 2001 From: Bernd Finger Date: Wed, 20 Dec 2023 11:58:36 +0100 Subject: [PATCH 1/4] sap_general_preconfigure: Make the role compatible with Ansible 2.16.1. Fixes issue #555. Signed-off-by: Bernd Finger --- .../tasks/RedHat/assert-installation.yml | 12 ++++++------ .../RedHat/generic/assert-dns-name-resolution.yml | 6 +++--- .../tasks/RedHat/generic/assert-etc-hosts.yml | 8 ++++---- .../tasks/RedHat/generic/assert-hostname.yml | 4 ++-- .../assert-kernel-parameters-loop-block.yml | 4 ++-- .../tasks/RedHat/generic/assert-nofile-limits.yml | 8 ++++---- .../tasks/RedHat/generic/assert-nproc-limits.yml | 8 ++++---- .../tasks/RedHat/generic/assert-selinux.yml | 4 ++-- .../tasks/RedHat/generic/assert-tmpfs.yml | 4 ++-- .../tasks/RedHat/generic/assert-uuidd.yml | 4 ++-- .../RedHat/generic/check-dns-name-resolution.yml | 14 -------------- .../tasks/RedHat/generic/configure-hostname.yml | 2 +- .../tasks/SLES/assert-installation.yml | 2 +- 13 files changed, 33 insertions(+), 47 deletions(-) diff --git a/roles/sap_general_preconfigure/tasks/RedHat/assert-installation.yml b/roles/sap_general_preconfigure/tasks/RedHat/assert-installation.yml index 7a8ce7ffc..2934456e6 100644 --- a/roles/sap_general_preconfigure/tasks/RedHat/assert-installation.yml +++ b/roles/sap_general_preconfigure/tasks/RedHat/assert-installation.yml @@ -52,7 +52,7 @@ - name: Assert that all required repos are enabled ansible.builtin.assert: - that: "'{{ line_item }}' in __sap_general_preconfigure_register_enabled_repos_assert.stdout_lines" + that: line_item in __sap_general_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: @@ -73,7 +73,7 @@ - name: Assert that the RHEL release is locked correctly ansible.builtin.assert: - that: "__sap_general_preconfigure_register_subscription_manager_release_assert.stdout == '{{ ansible_distribution_version }}'" + that: __sap_general_preconfigure_register_subscription_manager_release_assert.stdout == ansible_distribution_version fail_msg: "FAIL: The RHEL release lock status is '{{ __sap_general_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 }}'." @@ -107,7 +107,7 @@ - name: Assert that all required RHEL 7 package groups are installed ansible.builtin.assert: - that: "'{{ line_item }}' in __sap_general_preconfigure_register_yum_group_assert.stdout_lines" + that: line_item in __sap_general_preconfigure_register_yum_group_assert.stdout_lines fail_msg: "FAIL: Package group '{{ line_item }}' is not installed!" success_msg: "PASS: Package group '{{ line_item }}' is installed." loop: "{{ sap_general_preconfigure_packagegroups | map('replace', '@', '') | list }}" @@ -136,7 +136,7 @@ - name: Assert that all required RHEL 8 environment groups are installed ansible.builtin.assert: - that: "'{{ line_item }}' in __sap_general_preconfigure_register_yum_envgroup_assert.stdout_lines" + that: line_item in __sap_general_preconfigure_register_yum_envgroup_assert.stdout_lines fail_msg: "FAIL: Environment group '{{ line_item }}' is not installed!" success_msg: "PASS: Environment group '{{ line_item }}' is installed." with_items: @@ -147,7 +147,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: @@ -166,7 +166,7 @@ - name: Assert that all required IBM packages are installed ansible.builtin.assert: - that: "'{{ line_item }}' in __sap_general_preconfigure_register_required_ppc64le_packages_assert.stdout_lines" + that: line_item in __sap_general_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_general_preconfigure/tasks/RedHat/generic/assert-dns-name-resolution.yml b/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-dns-name-resolution.yml index 6d83943af..082f4bd31 100644 --- a/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-dns-name-resolution.yml +++ b/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-dns-name-resolution.yml @@ -37,7 +37,7 @@ - name: Assert that sap_ip is set ansible.builtin.assert: - that: "__sap_general_preconfigure_register_dig_short_assert.stdout == '{{ sap_ip }}'" + that: __sap_general_preconfigure_register_dig_short_assert.stdout == sap_ip fail_msg: "FAIL: The variable 'sap_ip' is not set!" success_msg: "PASS: The variable 'sap_ip' is set." ignore_errors: "{{ sap_general_preconfigure_assert_ignore_errors | d(false) }}" @@ -53,7 +53,7 @@ - name: Assert that the IP address for sap_hostname is resolved correctly ansible.builtin.assert: - that: "__sap_general_preconfigure_register_dig_search_short_assert.stdout == '{{ sap_ip }}'" + that: __sap_general_preconfigure_register_dig_search_short_assert.stdout == sap_ip fail_msg: "FAIL: The IP address for 'sap_hostname' could not be resolved!" success_msg: "PASS: The IP address for 'sap_hostname' was resolved." ignore_errors: "{{ sap_general_preconfigure_assert_ignore_errors | d(true) }}" @@ -68,7 +68,7 @@ - name: Assert that the reverse name resolution is correct ansible.builtin.assert: - that: "__sap_general_preconfigure_register_dig_reverse_assert.stdout == '{{ sap_hostname }}.{{ sap_domain }}.'" + that: __sap_general_preconfigure_register_dig_reverse_assert.stdout == sap_hostname + '.' + sap_domain + '.' fail_msg: "FAIL: The reverse name resolution of 'sap_ip' was not successful!" success_msg: "PASS: The reverse name resolution of 'sap_ip' was successful." ignore_errors: "{{ sap_general_preconfigure_assert_ignore_errors | d(true) }}" diff --git a/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-etc-hosts.yml b/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-etc-hosts.yml index 1de70c990..48b301f38 100644 --- a/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-etc-hosts.yml +++ b/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-etc-hosts.yml @@ -31,7 +31,7 @@ - name: Assert that ipv4 address, FQDN, and hostname are once in /etc/hosts ansible.builtin.assert: - that: "__sap_general_preconfigure_register_ipv4_fqdn_sap_hostname_once_assert.stdout == '1'" + that: __sap_general_preconfigure_register_ipv4_fqdn_sap_hostname_once_assert.stdout == '1' fail_msg: "FAIL: The line '{{ sap_ip }} {{ sap_hostname }}.{{ sap_domain }} {{ sap_hostname }}' needs to be once in /etc/hosts!" success_msg: "PASS: The line '{{ sap_ip }} {{ sap_hostname }}.{{ sap_domain }} {{ sap_hostname }}' is once in /etc/hosts." ignore_errors: "{{ sap_general_preconfigure_assert_ignore_errors | d(false) }}" @@ -52,7 +52,7 @@ - name: Assert that there is just one line containing {{ sap_ip }} in /etc/hosts ansible.builtin.assert: - that: "__sap_general_preconfigure_register_sap_ip_once_assert.stdout == '1'" + that: __sap_general_preconfigure_register_sap_ip_once_assert.stdout == '1' fail_msg: "FAIL: There is no line, or more than one line, containing '{{ sap_ip }}' in /etc/hosts!" success_msg: "PASS: There is only one line containing '{{ sap_ip }}' in /etc/hosts." ignore_errors: "{{ sap_general_preconfigure_assert_ignore_errors | d(false) }}" @@ -67,7 +67,7 @@ - name: Assert that there is just one line containing {{ sap_hostname }}.{{ sap_domain }} in /etc/hosts ansible.builtin.assert: - that: "__sap_general_preconfigure_register_fqdn_once_assert.stdout == '1'" + that: __sap_general_preconfigure_register_fqdn_once_assert.stdout == '1' fail_msg: "FAIL: There is no line, or more than one line, containing '{{ sap_hostname }}.{{ sap_domain }}' in /etc/hosts!" success_msg: "PASS: There is only one line containing '{{ sap_hostname }}.{{ sap_domain }}' in /etc/hosts." ignore_errors: "{{ sap_general_preconfigure_assert_ignore_errors | d(false) }}" @@ -82,7 +82,7 @@ - name: Assert that there is just one line containing {{ sap_hostname }} in /etc/hosts ansible.builtin.assert: - that: "__sap_general_preconfigure_register_sap_hostname_once_assert.stdout == '1'" + that: __sap_general_preconfigure_register_sap_hostname_once_assert.stdout == '1' fail_msg: "FAIL: There is no line, or more than one line, containing '{{ sap_hostname }}' in /etc/hosts!" success_msg: "PASS: There is only one line containing '{{ sap_hostname }}' in /etc/hosts." ignore_errors: "{{ sap_general_preconfigure_assert_ignore_errors | d(false) }}" diff --git a/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-hostname.yml b/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-hostname.yml index 64957c5dc..c0145be89 100644 --- a/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-hostname.yml +++ b/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-hostname.yml @@ -8,14 +8,14 @@ - name: Assert that the output of hostname matches the content of variable sap_hostname ansible.builtin.assert: - that: "__sap_general_preconfigure_register_hostname_assert.stdout == '{{ sap_hostname }}'" + that: __sap_general_preconfigure_register_hostname_assert.stdout == sap_hostname fail_msg: "FAIL: The output of 'hostname' does not match the content of variable 'sap_hostname'!" success_msg: "PASS: The output of 'hostname' matches the content of variable 'sap_hostname'." ignore_errors: "{{ sap_general_preconfigure_assert_ignore_errors | d(false) }}" - name: "Assert that the length of the hostname is not longer than 'sap_general_preconfigure_max_hostname_length'" ansible.builtin.assert: - that: "{{ sap_hostname | length | int }} <= {{ sap_general_preconfigure_max_hostname_length | int }}" + that: sap_hostname | length | int <= sap_general_preconfigure_max_hostname_length | int fail_msg: "FAIL: The length of the hostname is {{ sap_hostname | length | int }} but must be less or equal to {{ sap_general_preconfigure_max_hostname_length }} (variable 'sap_general_preconfigure_max_hostname_length')!" success_msg: "PASS: The length of the hostname is {{ sap_hostname | length | int }}, which is less or equal to {{ sap_general_preconfigure_max_hostname_length }} (variable 'sap_general_preconfigure_max_hostname_length')." ignore_errors: "{{ sap_general_preconfigure_assert_ignore_errors | d(false) }}" diff --git a/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-kernel-parameters-loop-block.yml b/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-kernel-parameters-loop-block.yml index d3b90e0ae..c87db29b0 100644 --- a/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-kernel-parameters-loop-block.yml +++ b/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-kernel-parameters-loop-block.yml @@ -11,7 +11,7 @@ - name: Assert that {{ line_item.name }} is set correctly in {{ sap_general_preconfigure_etc_sysctl_sap_conf }} ansible.builtin.assert: - that: "__sap_general_preconfigure_register_sysctl_sap_conf_kernel_parameter_assert.stdout == '{{ line_item.value }}'" + that: __sap_general_preconfigure_register_sysctl_sap_conf_kernel_parameter_assert.stdout == line_item.value fail_msg: "FAIL: The value of '{{ line_item.name }}' in '{{ sap_general_preconfigure_etc_sysctl_sap_conf }}' is '{{ __sap_general_preconfigure_register_sysctl_sap_conf_kernel_parameter_assert.stdout }}' but the expected value is '{{ line_item.value }}'!" success_msg: "PASS: The value of '{{ line_item.name }}' in '{{ sap_general_preconfigure_etc_sysctl_sap_conf }}' is @@ -27,7 +27,7 @@ - name: Assert that {{ line_item.name }} is set correctly as per sysctl ansible.builtin.assert: - that: "__sap_general_preconfigure_register_sysctl_kernel_parameter_assert.stdout == '{{ line_item.value }}'" + that: __sap_general_preconfigure_register_sysctl_kernel_parameter_assert.stdout == line_item.value fail_msg: "FAIL: The current value of '{{ line_item.name }}' as per sysctl is '{{ __sap_general_preconfigure_register_sysctl_kernel_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_general_preconfigure/tasks/RedHat/generic/assert-nofile-limits.yml b/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-nofile-limits.yml index c915bd3e4..6d549b96d 100644 --- a/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-nofile-limits.yml +++ b/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-nofile-limits.yml @@ -11,7 +11,7 @@ - name: Assert that the hard limit of nofile for group sapsys is 1048576 ansible.builtin.assert: - that: "__sap_general_preconfigure_register_limits_sap_conf_nofile_hard_assert.stdout == '1048576'" + that: __sap_general_preconfigure_register_limits_sap_conf_nofile_hard_assert.stdout == '1048576' fail_msg: "FAIL: The hard limit of nofile for group 'sapsys' in /etc/security/limits.d/99-sap.conf is '{{ __sap_general_preconfigure_register_limits_sap_conf_nofile_hard_assert.stdout }}' but the expected value is 1048576 !" success_msg: "PASS: The hard limit of nofile for group 'sapsys' in /etc/security/limits.d/99-sap.conf is @@ -32,7 +32,7 @@ - name: Assert that the soft limit of nofile for group sapsys is 1048576 ansible.builtin.assert: - that: "__sap_general_preconfigure_register_limits_sap_conf_nofile_soft_assert.stdout == '1048576'" + that: __sap_general_preconfigure_register_limits_sap_conf_nofile_soft_assert.stdout == '1048576' fail_msg: "FAIL: The soft limit of nofile for group 'sapsys' in /etc/security/limits.d/99-sap.conf is '{{ __sap_general_preconfigure_register_limits_sap_conf_nofile_soft_assert.stdout }}' but the expected value is 1048576 !" success_msg: "PASS: The soft limit of nofile for group 'sapsys' in /etc/security/limits.d/99-sap.conf is @@ -54,7 +54,7 @@ - name: Assert that the hard limit of nofile for the database group is 1048576 ansible.builtin.assert: - that: "__sap_general_preconfigure_register_limits_sap_conf_db_group_nofile_hard_assert.stdout == '1048576'" + that: __sap_general_preconfigure_register_limits_sap_conf_db_group_nofile_hard_assert.stdout == '1048576' fail_msg: "FAIL: The hard limit of nofile for group '{{ sap_general_preconfigure_db_group_name }}' is not set to '1048576' in /etc/security/limits.d/99-sap.conf!" success_msg: "PASS: The hard limit of nofile for group '{{ sap_general_preconfigure_db_group_name }}' is set to '1048576' in /etc/security/limits.d/99-sap.conf." ignore_errors: "{{ sap_general_preconfigure_assert_ignore_errors | d(false) }}" @@ -75,7 +75,7 @@ - name: Assert that the soft limit of nofile for the database group is 1048576 ansible.builtin.assert: - that: "__sap_general_preconfigure_register_limits_sap_conf_db_group_nofile_soft_assert.stdout == '1048576'" + that: __sap_general_preconfigure_register_limits_sap_conf_db_group_nofile_soft_assert.stdout == '1048576' fail_msg: "FAIL: The soft limit of nofile for group '{{ sap_general_preconfigure_db_group_name }}' is not set to '1048576' in /etc/security/limits.d/99-sap.conf!" success_msg: "PASS: The soft limit of nofile for group '{{ sap_general_preconfigure_db_group_name }}' is set to '1048576' in /etc/security/limits.d/99-sap.conf." ignore_errors: "{{ sap_general_preconfigure_assert_ignore_errors | d(false) }}" diff --git a/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-nproc-limits.yml b/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-nproc-limits.yml index 9edf3e320..0a24bcd15 100644 --- a/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-nproc-limits.yml +++ b/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-nproc-limits.yml @@ -11,7 +11,7 @@ - name: Assert that the hard limit of nproc for group sapsys is unlimited ansible.builtin.assert: - that: "__sap_general_preconfigure_register_limits_sap_conf_nproc_hard_assert.stdout == 'unlimited'" + that: __sap_general_preconfigure_register_limits_sap_conf_nproc_hard_assert.stdout == 'unlimited' fail_msg: "FAIL: The hard limit of nproc for group 'sapsys' in /etc/security/limits.d/99-sap.conf is '{{ __sap_general_preconfigure_register_limits_sap_conf_nproc_hard_assert.stdout }}' but the expected value is 'unlimited'!" success_msg: "PASS: The hard limit of nproc for group 'sapsys' in /etc/security/limits.d/99-sap.conf is @@ -32,7 +32,7 @@ - name: Assert that the soft limit of nproc for group sapsys is unlimited ansible.builtin.assert: - that: "__sap_general_preconfigure_register_limits_sap_conf_nproc_soft_assert.stdout == 'unlimited'" + that: __sap_general_preconfigure_register_limits_sap_conf_nproc_soft_assert.stdout == 'unlimited' fail_msg: "FAIL: The soft limit of nproc for group 'sapsys' in /etc/security/limits.d/99-sap.conf is '{{ __sap_general_preconfigure_register_limits_sap_conf_nproc_hard_assert.stdout }}' but the expected value is 'unlimited'!" success_msg: "PASS: The soft limit of nproc for group 'sapsys' in /etc/security/limits.d/99-sap.conf is @@ -54,7 +54,7 @@ - name: Assert that the hard limit of nproc for the database group is unlimited ansible.builtin.assert: - that: "__sap_general_preconfigure_register_limits_sap_conf_db_group_nproc_hard_assert.stdout == 'unlimited'" + that: __sap_general_preconfigure_register_limits_sap_conf_db_group_nproc_hard_assert.stdout == 'unlimited' fail_msg: "FAIL: The hard limit of nproc for group '{{ sap_general_preconfigure_db_group_name }}' in /etc/security/limits.d/99-sap.conf is '{{ __sap_general_preconfigure_register_limits_sap_conf_db_group_nproc_hard_assert.stdout }}' but the expected value is 'unlimited'!" success_msg: "PASS: The hard limit of nproc for group '{{ sap_general_preconfigure_db_group_name }}' in /etc/security/limits.d/99-sap.conf is @@ -77,7 +77,7 @@ - name: Assert that the soft limit of nproc for the database group is unlimited ansible.builtin.assert: - that: "__sap_general_preconfigure_register_limits_sap_conf_db_group_nproc_soft_assert.stdout == 'unlimited'" + that: __sap_general_preconfigure_register_limits_sap_conf_db_group_nproc_soft_assert.stdout == 'unlimited' fail_msg: "FAIL: The soft limit of nproc for group '{{ sap_general_preconfigure_db_group_name }}' in /etc/security/limits.d/99-sap.conf is '{{ __sap_general_preconfigure_register_limits_sap_conf_db_group_nproc_soft_assert.stdout }}' but the expected value is 'unlimited'!" success_msg: "PASS: The soft limit of nproc for group '{{ sap_general_preconfigure_db_group_name }}' in /etc/security/limits.d/99-sap.conf is diff --git a/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-selinux.yml b/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-selinux.yml index 7a41cf16a..ca60ba951 100644 --- a/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-selinux.yml +++ b/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-selinux.yml @@ -34,7 +34,7 @@ - name: "Assert that the permanent configuration of the SELinux state is set to '{{ sap_general_preconfigure_selinux_state }}'" ansible.builtin.assert: - that: __sap_general_preconfigure_register_selinux_conf_assert.stdout == "{{ sap_general_preconfigure_selinux_state }}" + that: __sap_general_preconfigure_register_selinux_conf_assert.stdout == sap_general_preconfigure_selinux_state fail_msg: "FAIL: The system is not configured for the SELinux state of '{{ sap_general_preconfigure_selinux_state }}'. Current configuration: '{{ __sap_general_preconfigure_register_selinux_conf_assert.stdout }}'." success_msg: "PASS: The system is configured for the SELinux state of '{{ sap_general_preconfigure_selinux_state }}'" @@ -48,7 +48,7 @@ - name: Assert that the SELinux state is set correctly ansible.builtin.assert: - that: __sap_general_preconfigure_register_getenforce_assert.stdout | lower == "{{ sap_general_preconfigure_selinux_state }}" + that: __sap_general_preconfigure_register_getenforce_assert.stdout | lower == sap_general_preconfigure_selinux_state fail_msg: "FAIL: SELinux is currently not '{{ sap_general_preconfigure_selinux_state }}'! The current SELinux state is: '{{ __sap_general_preconfigure_register_getenforce_assert.stdout | lower }}'." success_msg: "PASS: SELinux is currently {{ sap_general_preconfigure_selinux_state }}." diff --git a/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-tmpfs.yml b/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-tmpfs.yml index 748e31be9..5d898c866 100644 --- a/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-tmpfs.yml +++ b/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-tmpfs.yml @@ -15,7 +15,7 @@ - name: Assert that the size of tmpfs is large enough as per /etc/fstab ansible.builtin.assert: - that: "'{{ sap_general_preconfigure_size_of_tmpfs_gb }}G' in __sap_general_preconfigure_register_fstab_tmpfs_size_gb_assert.stdout" + that: sap_general_preconfigure_size_of_tmpfs_gb + 'G' in __sap_general_preconfigure_register_fstab_tmpfs_size_gb_assert.stdout fail_msg: "FAIL: The size of tmpfs in /etc/fstab is '{{ __sap_general_preconfigure_register_fstab_tmpfs_size_gb_assert.stdout }}' but the expected size is '{{ sap_general_preconfigure_size_of_tmpfs_gb }}G'!" success_msg: "PASS: The size of tmpfs in /etc/fstab is '{{ __sap_general_preconfigure_register_fstab_tmpfs_size_gb_assert.stdout }}'." @@ -30,7 +30,7 @@ - name: Assert that the current size of tmpfs is large enough as per df output ansible.builtin.assert: - that: "__sap_general_preconfigure_register_df_shm_assert.stdout == '{{ sap_general_preconfigure_size_of_tmpfs_gb }}G'" + that: __sap_general_preconfigure_register_df_shm_assert.stdout == sap_general_preconfigure_size_of_tmpfs_gb + 'G' fail_msg: "FAIL: The current size of tmpfs is '{{ __sap_general_preconfigure_register_df_shm_assert.stdout }}' but the expected size is '{{ sap_general_preconfigure_size_of_tmpfs_gb }}G'!" success_msg: "PASS: The current size of tmpfs is '{{ __sap_general_preconfigure_register_df_shm_assert.stdout }}'." diff --git a/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-uuidd.yml b/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-uuidd.yml index 0951483f9..cd78d9b42 100644 --- a/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-uuidd.yml +++ b/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-uuidd.yml @@ -35,8 +35,8 @@ - name: Assert that uuidd.socket is active ansible.builtin.assert: - that: "'active (running)' in __sap_general_preconfigure_register_uuidd_socket_status_assert.stdout or 'active (listening)' - in __sap_general_preconfigure_register_uuidd_socket_status_assert.stdout" + that: "'active (running)' in __sap_general_preconfigure_register_uuidd_socket_status_assert.stdout or + 'active (listening)' in __sap_general_preconfigure_register_uuidd_socket_status_assert.stdout" fail_msg: "FAIL: Service 'uuidd.socket' is not active!" success_msg: "PASS: Service 'uuidd.socket' is active." ignore_errors: "{{ sap_general_preconfigure_assert_ignore_errors | d(false) }}" diff --git a/roles/sap_general_preconfigure/tasks/RedHat/generic/check-dns-name-resolution.yml b/roles/sap_general_preconfigure/tasks/RedHat/generic/check-dns-name-resolution.yml index 994c3998b..42ca53351 100644 --- a/roles/sap_general_preconfigure/tasks/RedHat/generic/check-dns-name-resolution.yml +++ b/roles/sap_general_preconfigure/tasks/RedHat/generic/check-dns-name-resolution.yml @@ -1,19 +1,5 @@ --- -# moved to configure-etc-hosts.yml: -#- name: Verify that the DNS domain is set -# assert: -# that: -# not( (sap_domain is undefined) or (sap_domain is none) or (sap_domain | trim == '') ) -# msg: "You need to define the variable 'sap_domain' in defaults/main.yml." - -### DNS is not that necessary and as such the errors are ignored -### for production it is strongly recommended to have proper DNS setup -# - name: Ensure dig command is installed -# package: -# name: bind-utils -# state: present - - name: Check dns forwarding settings ansible.builtin.shell: test "$(dig {{ sap_hostname }}.{{ sap_domain }} +short)" = "{{ sap_ip }}" changed_when: false diff --git a/roles/sap_general_preconfigure/tasks/RedHat/generic/configure-hostname.yml b/roles/sap_general_preconfigure/tasks/RedHat/generic/configure-hostname.yml index 12c0123bb..30756fed2 100644 --- a/roles/sap_general_preconfigure/tasks/RedHat/generic/configure-hostname.yml +++ b/roles/sap_general_preconfigure/tasks/RedHat/generic/configure-hostname.yml @@ -50,5 +50,5 @@ - name: "Ensure that the length of the hostname is not longer than 'sap_general_preconfigure_max_hostname_length'" ansible.builtin.assert: - that: "{{ sap_hostname | length | int }} <= {{ sap_general_preconfigure_max_hostname_length | int }}" + that: sap_hostname | length | int <= sap_general_preconfigure_max_hostname_length | int msg: "The length of the hostname is {{ sap_hostname | length | int }} but must be less or equal to {{ sap_general_preconfigure_max_hostname_length }} (variable 'sap_general_preconfigure_max_hostname_length')!" diff --git a/roles/sap_general_preconfigure/tasks/SLES/assert-installation.yml b/roles/sap_general_preconfigure/tasks/SLES/assert-installation.yml index e5ebe479a..4b5e489e2 100644 --- a/roles/sap_general_preconfigure/tasks/SLES/assert-installation.yml +++ b/roles/sap_general_preconfigure/tasks/SLES/assert-installation.yml @@ -2,7 +2,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: From 2eae3a5de6cd689df93be874c159eeb821f8717a Mon Sep 17 00:00:00 2001 From: Bernd Finger Date: Wed, 20 Dec 2023 13:57:02 +0100 Subject: [PATCH 2/4] sap_general_preconfigure: add missing ignore_errors for IBM package Signed-off-by: Bernd Finger --- .../tasks/RedHat/assert-installation.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/roles/sap_general_preconfigure/tasks/RedHat/assert-installation.yml b/roles/sap_general_preconfigure/tasks/RedHat/assert-installation.yml index 2934456e6..a08b3e47a 100644 --- a/roles/sap_general_preconfigure/tasks/RedHat/assert-installation.yml +++ b/roles/sap_general_preconfigure/tasks/RedHat/assert-installation.yml @@ -163,6 +163,7 @@ register: __sap_general_preconfigure_register_required_ppc64le_packages_assert changed_when: no when: ansible_architecture == "ppc64le" + ignore_errors: "{{ sap_general_preconfigure_assert_ignore_errors | d(false) }}" - name: Assert that all required IBM packages are installed ansible.builtin.assert: From f1d6f2e01752f6edfee69fa89192853597357ee5 Mon Sep 17 00:00:00 2001 From: Bernd Finger Date: Wed, 20 Dec 2023 15:15:21 +0100 Subject: [PATCH 3/4] sap_general_preconfigure: Add parentheses for 'that:' elements For comparison expressions, readability decreased after removing the double braces around expressions which contain more than one member on any side of the operator. With parentheses, we should get back the same level of readability again. Signed-off-by: Bernd Finger --- .../tasks/RedHat/generic/assert-dns-name-resolution.yml | 2 +- .../tasks/RedHat/generic/assert-hostname.yml | 2 +- .../tasks/RedHat/generic/assert-selinux.yml | 6 +++--- .../tasks/RedHat/generic/assert-tmpfs.yml | 4 ++-- .../tasks/RedHat/generic/configure-hostname.yml | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-dns-name-resolution.yml b/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-dns-name-resolution.yml index 082f4bd31..c7df9b1b3 100644 --- a/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-dns-name-resolution.yml +++ b/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-dns-name-resolution.yml @@ -68,7 +68,7 @@ - name: Assert that the reverse name resolution is correct ansible.builtin.assert: - that: __sap_general_preconfigure_register_dig_reverse_assert.stdout == sap_hostname + '.' + sap_domain + '.' + that: __sap_general_preconfigure_register_dig_reverse_assert.stdout == (sap_hostname + '.' + sap_domain + '.') fail_msg: "FAIL: The reverse name resolution of 'sap_ip' was not successful!" success_msg: "PASS: The reverse name resolution of 'sap_ip' was successful." ignore_errors: "{{ sap_general_preconfigure_assert_ignore_errors | d(true) }}" diff --git a/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-hostname.yml b/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-hostname.yml index c0145be89..0ee9b8972 100644 --- a/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-hostname.yml +++ b/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-hostname.yml @@ -15,7 +15,7 @@ - name: "Assert that the length of the hostname is not longer than 'sap_general_preconfigure_max_hostname_length'" ansible.builtin.assert: - that: sap_hostname | length | int <= sap_general_preconfigure_max_hostname_length | int + that: (sap_hostname | length | int) <= (sap_general_preconfigure_max_hostname_length | int) fail_msg: "FAIL: The length of the hostname is {{ sap_hostname | length | int }} but must be less or equal to {{ sap_general_preconfigure_max_hostname_length }} (variable 'sap_general_preconfigure_max_hostname_length')!" success_msg: "PASS: The length of the hostname is {{ sap_hostname | length | int }}, which is less or equal to {{ sap_general_preconfigure_max_hostname_length }} (variable 'sap_general_preconfigure_max_hostname_length')." ignore_errors: "{{ sap_general_preconfigure_assert_ignore_errors | d(false) }}" diff --git a/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-selinux.yml b/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-selinux.yml index ca60ba951..bf9cf759a 100644 --- a/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-selinux.yml +++ b/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-selinux.yml @@ -48,7 +48,7 @@ - name: Assert that the SELinux state is set correctly ansible.builtin.assert: - that: __sap_general_preconfigure_register_getenforce_assert.stdout | lower == sap_general_preconfigure_selinux_state + that: (__sap_general_preconfigure_register_getenforce_assert.stdout | lower) == sap_general_preconfigure_selinux_state fail_msg: "FAIL: SELinux is currently not '{{ sap_general_preconfigure_selinux_state }}'! The current SELinux state is: '{{ __sap_general_preconfigure_register_getenforce_assert.stdout | lower }}'." success_msg: "PASS: SELinux is currently {{ sap_general_preconfigure_selinux_state }}." @@ -89,7 +89,7 @@ - name: Assert that there is an entry for '/usr/sap' in the SELinux configuration database ansible.builtin.assert: - that: __sap_general_preconfigure_register_semanage_fcontext_usr_sap.stdout | int != 0 + that: (__sap_general_preconfigure_register_semanage_fcontext_usr_sap.stdout | int) != 0 fail_msg: "FAIL: There is no entry for '/usr/sap' in the SELinux configuration database!" success_msg: "PASS: There is an entry for '/usr/sap' in the SELinux configuration database." ignore_errors: "{{ sap_general_preconfigure_assert_ignore_errors | d(false) }}" @@ -107,7 +107,7 @@ - name: Assert that all files in '/usr/sap' and below have the 'usr_t' file context ansible.builtin.assert: - that: __sap_general_preconfigure_register_ls_z_usr_sap.stdout | int == 0 + that: (__sap_general_preconfigure_register_ls_z_usr_sap.stdout | int) == 0 fail_msg: "FAIL: There is at least one file in '/usr/sap' or below without the 'usr_t' file context!" success_msg: "PASS: All files in '/usr/sap' and below have the 'usr_t' file context." ignore_errors: "{{ sap_general_preconfigure_assert_ignore_errors | d(false) }}" diff --git a/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-tmpfs.yml b/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-tmpfs.yml index 5d898c866..e7cfda454 100644 --- a/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-tmpfs.yml +++ b/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-tmpfs.yml @@ -15,7 +15,7 @@ - name: Assert that the size of tmpfs is large enough as per /etc/fstab ansible.builtin.assert: - that: sap_general_preconfigure_size_of_tmpfs_gb + 'G' in __sap_general_preconfigure_register_fstab_tmpfs_size_gb_assert.stdout + that: (sap_general_preconfigure_size_of_tmpfs_gb + 'G') in __sap_general_preconfigure_register_fstab_tmpfs_size_gb_assert.stdout fail_msg: "FAIL: The size of tmpfs in /etc/fstab is '{{ __sap_general_preconfigure_register_fstab_tmpfs_size_gb_assert.stdout }}' but the expected size is '{{ sap_general_preconfigure_size_of_tmpfs_gb }}G'!" success_msg: "PASS: The size of tmpfs in /etc/fstab is '{{ __sap_general_preconfigure_register_fstab_tmpfs_size_gb_assert.stdout }}'." @@ -30,7 +30,7 @@ - name: Assert that the current size of tmpfs is large enough as per df output ansible.builtin.assert: - that: __sap_general_preconfigure_register_df_shm_assert.stdout == sap_general_preconfigure_size_of_tmpfs_gb + 'G' + that: __sap_general_preconfigure_register_df_shm_assert.stdout == (sap_general_preconfigure_size_of_tmpfs_gb + 'G') fail_msg: "FAIL: The current size of tmpfs is '{{ __sap_general_preconfigure_register_df_shm_assert.stdout }}' but the expected size is '{{ sap_general_preconfigure_size_of_tmpfs_gb }}G'!" success_msg: "PASS: The current size of tmpfs is '{{ __sap_general_preconfigure_register_df_shm_assert.stdout }}'." diff --git a/roles/sap_general_preconfigure/tasks/RedHat/generic/configure-hostname.yml b/roles/sap_general_preconfigure/tasks/RedHat/generic/configure-hostname.yml index 30756fed2..9d3798601 100644 --- a/roles/sap_general_preconfigure/tasks/RedHat/generic/configure-hostname.yml +++ b/roles/sap_general_preconfigure/tasks/RedHat/generic/configure-hostname.yml @@ -50,5 +50,5 @@ - name: "Ensure that the length of the hostname is not longer than 'sap_general_preconfigure_max_hostname_length'" ansible.builtin.assert: - that: sap_hostname | length | int <= sap_general_preconfigure_max_hostname_length | int + that: (sap_hostname | length | int) <= (sap_general_preconfigure_max_hostname_length | int) msg: "The length of the hostname is {{ sap_hostname | length | int }} but must be less or equal to {{ sap_general_preconfigure_max_hostname_length }} (variable 'sap_general_preconfigure_max_hostname_length')!" From 0607852c555cda7365dbaf9d844e68afe3c15430 Mon Sep 17 00:00:00 2001 From: Bernd Finger Date: Thu, 21 Dec 2023 10:35:31 +0100 Subject: [PATCH 4/4] sap_general_preconfigure: add parentheses to one more that: statement Signed-off-by: Bernd Finger --- .../tasks/RedHat/generic/assert-tmpfs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-tmpfs.yml b/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-tmpfs.yml index e7cfda454..81e5e175c 100644 --- a/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-tmpfs.yml +++ b/roles/sap_general_preconfigure/tasks/RedHat/generic/assert-tmpfs.yml @@ -8,7 +8,7 @@ - name: Assert that there is an entry for tmpfs in /etc/fstab ansible.builtin.assert: - that: __sap_general_preconfigure_register_fstab_tmpfs_size_gb_assert.stdout | length > 0 + that: (__sap_general_preconfigure_register_fstab_tmpfs_size_gb_assert.stdout | length) > 0 fail_msg: "FAIL: There is no entry for 'tmpfs' in /etc/fstab!" success_msg: "PASS: An entry for 'tmpfs' in /etc/fstab exists." ignore_errors: "{{ sap_general_preconfigure_assert_ignore_errors | d(false) }}"