Skip to content

Commit

Permalink
Merge pull request #914 from mk-ansible-roles/issue-907
Browse files Browse the repository at this point in the history
sap_general_preconfigure - Checking for english locales, issue 907
  • Loading branch information
berndfinger authored Jan 13, 2025
2 parents d04883f + de43ef4 commit b0f1a89
Show file tree
Hide file tree
Showing 11 changed files with 143 additions and 1 deletion.
3 changes: 3 additions & 0 deletions roles/sap_general_preconfigure/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,7 @@ sap_general_preconfigure_domain: "{{ sap_domain | d(ansible_domain) }}"
# Configuring Process Resource Limits
# Example: See README.md

# in SAP Note 2369910 SAP requires English locale
# If you want to define the locale set this to e.g. en_US.UTF-8
sap_general_preconfigure_default_locale: ""
# END: Default Variables for sap_general_preconfigure
8 changes: 8 additions & 0 deletions roles/sap_general_preconfigure/meta/argument_specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -347,3 +347,11 @@ argument_specs:
sap_general_preconfigure_db_group_name: 'dba'
required: false
type: str

sap_general_preconfigure_default_locale:
description:
- Use this variable to specify the default system locale.
example:
sap_general_preconfigure_default_locale: 'en_US.UTF-8'
required: false
type: str
38 changes: 38 additions & 0 deletions roles/sap_general_preconfigure/tasks/sapnote/2369910.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# SPDX-License-Identifier: Apache-2.0
---
- name: Configure - Display SAP note number 2369910 and its version
ansible.builtin.debug:
msg: "SAP note {{ (__sap_general_preconfigure_sapnotes_versions | selectattr('number', 'match', '^2369910$') | first).number }}
(version {{ (__sap_general_preconfigure_sapnotes_versions | selectattr('number', 'match', '^2369910$') | first).version }}): SAP Software on Linux: General Information"
tags:
- always

- name: Check locales
when: sap_general_preconfigure_config_all | d(true) or sap_general_preconfigure_2369910 | d(false)
tags:
- sap_general_preconfigure_2369910
- sap_general_preconfigure_configure_locale
block:
- name: Configure an English locale
when:
- sap_general_preconfigure_default_locale is defined and sap_general_preconfigure_default_locale
- sap_general_preconfigure_default_locale == 'C.UTF-8' or
sap_general_preconfigure_default_locale == 'C.utf8' or
sap_general_preconfigure_default_locale.startswith('en_') and
(sap_general_preconfigure_default_locale.endswith('UTF-8') or
sap_general_preconfigure_default_locale.endswith('utf8'))
ansible.builtin.command: "localectl set-locale LANG={{ sap_general_preconfigure_default_locale }}"
changed_when: true

- name: Get the current default locale
ansible.builtin.command: awk '{gsub("\"","")}/^LANG=/&&(/=C\./||/=en_/)&&(/utf8$/||/UTF-8$/){print}' /etc/locale.conf
changed_when: false
register: __sap_general_preconfigure_current_default_locale

- name: Assert that an English locale is the default
ansible.builtin.assert:
that: __sap_general_preconfigure_current_default_locale.stdout_lines | length > 0
fail_msg: >
"FAIL: English is not set as the default locale. Please define an English default locale
with the 'sap_general_preconfigure_default_locale' variable!"
success_msg: "PASS: An English default locale is set."
36 changes: 36 additions & 0 deletions roles/sap_general_preconfigure/tasks/sapnote/assert-2369910.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# SPDX-License-Identifier: Apache-2.0
---
- name: Assert - Display SAP note number 2369910 and its version
ansible.builtin.debug:
msg: "SAP note {{ (__sap_general_preconfigure_sapnotes_versions | selectattr('number', 'match', '^2369910$') | first).number }}
(version {{ (__sap_general_preconfigure_sapnotes_versions | selectattr('number', 'match', '^2369910$') | first).version }}): SAP Software on Linux: General Information"
tags:
- always

## STEP 3.1 -- System Language
- name: Step 3.1 - Check if English Language is installed
tags:
- sap_general_preconfigure_2369910
- sap_general_preconfigure_2369910_03
block:
- name: Get list of installed locales
ansible.builtin.command: locale -a
changed_when: false
register: __sap_general_preconfigure_locales_installed

- name: Assert that an English locale is installed
ansible.builtin.assert:
that: __sap_general_preconfigure_locales_installed.stdout_lines | select('match', '^en_') | list | length > 0
fail_msg: "FAIL: No English locale is installed. Please install an English locale!"
success_msg: "PASS: An English locale is installed."

- name: Get the current default locale
ansible.builtin.command: awk '{gsub("\"","")}/^LANG=/&&(/=C\./||/=en_/)&&(/utf8$/||/UTF-8$/){print}' /etc/locale.conf
changed_when: false
register: __sap_general_preconfigure_current_default_locale

- name: Assert that an English locale is the default
ansible.builtin.assert:
that: __sap_general_preconfigure_current_default_locale.stdout_lines | length > 0
fail_msg: "FAIL: English is not set as the default locale. Please define a valid English default locale with the variable 'sap_general_preconfigure_default_locale' !"
success_msg: "PASS: An English default locale is set."
13 changes: 13 additions & 0 deletions roles/sap_general_preconfigure/vars/RedHat_7.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# vars file for sap_general_preconfigure

__sap_general_preconfigure_sapnotes_versions:
- { number: '2369910', version: '18' }
- { number: '2002167', version: '36' }
- { number: '1771258', version: '6' }
- { number: '1391070', version: '41' }
Expand Down Expand Up @@ -93,6 +94,9 @@ __sap_general_preconfigure_packages_x86_64:
- compat-sap-c++-7
- compat-sap-c++-9
- compat-sap-c++-10
# English locale packages are required as per SAP note 2369910:
- langpacks-en
- glibc-langpack-en

__sap_general_preconfigure_packages_ppc64le:
- uuidd
Expand All @@ -103,17 +107,26 @@ __sap_general_preconfigure_packages_ppc64le:
- compat-sap-c++-7
- compat-sap-c++-9
- compat-sap-c++-10
# English locale packages are required as per SAP note 2369910:
- langpacks-en
- glibc-langpack-en

__sap_general_preconfigure_packages_ppc64:
- uuidd
- tcsh
- psmisc
- compat-sap-c++-5
# English locale packages are required as per SAP note 2369910:
- langpacks-en
- glibc-langpack-en

__sap_general_preconfigure_packages_s390x:
- uuidd
- tcsh
- psmisc
# English locale packages are required as per SAP note 2369910:
- langpacks-en
- glibc-langpack-en

__sap_general_preconfigure_packages: "{{ lookup('vars', '__sap_general_preconfigure_packages_' + ansible_architecture) }}"

Expand Down
4 changes: 4 additions & 0 deletions roles/sap_general_preconfigure/vars/RedHat_8.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# vars file for sap_general_preconfigure

__sap_general_preconfigure_sapnotes_versions:
- { number: '2369910', version: '18' }
- { number: '2772999', version: '24' }
- { number: '1771258', version: '6' }

Expand Down Expand Up @@ -47,6 +48,9 @@ __sap_general_preconfigure_packages:
- psmisc
- nfs-utils
- bind-utils
# English locale packages are required as per SAP note 2369910:
- langpacks-en
- glibc-langpack-en

__sap_general_preconfigure_required_ppc64le:
- ibm-power-managed-rhel8
Expand Down
10 changes: 10 additions & 0 deletions roles/sap_general_preconfigure/vars/RedHat_8.1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# vars file for sap_general_preconfigure

__sap_general_preconfigure_sapnotes_versions:
- { number: '2369910', version: '18' }
- { number: '2772999', version: '24' }
- { number: '1771258', version: '6' }

Expand Down Expand Up @@ -49,6 +50,9 @@ __sap_general_preconfigure_packages_x86_64:
- bind-utils
- compat-sap-c++-9
- compat-sap-c++-10
# English locale packages are required as per SAP note 2369910:
- langpacks-en
- glibc-langpack-en

__sap_general_preconfigure_packages_ppc64le:
- uuidd
Expand All @@ -59,6 +63,9 @@ __sap_general_preconfigure_packages_ppc64le:
- bind-utils
- compat-sap-c++-9
- compat-sap-c++-10
# English locale packages are required as per SAP note 2369910:
- langpacks-en
- glibc-langpack-en

__sap_general_preconfigure_packages_s390x:
- uuidd
Expand All @@ -67,6 +74,9 @@ __sap_general_preconfigure_packages_s390x:
- psmisc
- nfs-utils
- bind-utils
# English locale packages are required as per SAP note 2369910:
- langpacks-en
- glibc-langpack-en

__sap_general_preconfigure_packages: "{{ lookup('vars', '__sap_general_preconfigure_packages_' + ansible_architecture) }}"

Expand Down
10 changes: 10 additions & 0 deletions roles/sap_general_preconfigure/vars/RedHat_8.2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# vars file for sap_general_preconfigure

__sap_general_preconfigure_sapnotes_versions:
- { number: '2369910', version: '18' }
- { number: '2772999', version: '24' }
- { number: '1771258', version: '6' }

Expand Down Expand Up @@ -49,6 +50,9 @@ __sap_general_preconfigure_packages_x86_64:
- bind-utils
- compat-sap-c++-9
- compat-sap-c++-10
# English locale packages are required as per SAP note 2369910:
- langpacks-en
- glibc-langpack-en

__sap_general_preconfigure_packages_ppc64le:
- uuidd
Expand All @@ -59,6 +63,9 @@ __sap_general_preconfigure_packages_ppc64le:
- bind-utils
- compat-sap-c++-9
- compat-sap-c++-10
# English locale packages are required as per SAP note 2369910:
- langpacks-en
- glibc-langpack-en

__sap_general_preconfigure_packages_s390x:
- uuidd
Expand All @@ -67,6 +74,9 @@ __sap_general_preconfigure_packages_s390x:
- psmisc
- nfs-utils
- bind-utils
# English locale packages are required as per SAP note 2369910:
- langpacks-en
- glibc-langpack-en

__sap_general_preconfigure_packages: "{{ lookup('vars', '__sap_general_preconfigure_packages_' + ansible_architecture) }}"

Expand Down
10 changes: 10 additions & 0 deletions roles/sap_general_preconfigure/vars/RedHat_8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# vars file for sap_general_preconfigure

__sap_general_preconfigure_sapnotes_versions:
- { number: '2369910', version: '18' }
- { number: '2772999', version: '24' }
- { number: '1771258', version: '6' }

Expand Down Expand Up @@ -59,6 +60,9 @@ __sap_general_preconfigure_packages_x86_64:
- compat-sap-c++-9
- compat-sap-c++-10
- compat-sap-c++-11
# English locale packages are required as per SAP note 2369910:
- langpacks-en
- glibc-langpack-en

__sap_general_preconfigure_packages_ppc64le:
- uuidd
Expand All @@ -70,6 +74,9 @@ __sap_general_preconfigure_packages_ppc64le:
- compat-sap-c++-9
- compat-sap-c++-10
- compat-sap-c++-11
# English locale packages are required as per SAP note 2369910:
- langpacks-en
- glibc-langpack-en

__sap_general_preconfigure_packages_s390x:
- uuidd
Expand All @@ -79,6 +86,9 @@ __sap_general_preconfigure_packages_s390x:
- nfs-utils
- bind-utils
- compat-sap-c++-10
# English locale packages are required as per SAP note 2369910:
- langpacks-en
- glibc-langpack-en

__sap_general_preconfigure_packages: "{{ lookup('vars', '__sap_general_preconfigure_packages_' + ansible_architecture) }}"

Expand Down
10 changes: 10 additions & 0 deletions roles/sap_general_preconfigure/vars/RedHat_9.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# vars file for sap_general_preconfigure

__sap_general_preconfigure_sapnotes_versions:
- { number: '2369910', version: '18' }
- { number: '3108316', version: '2' }
- { number: '1771258', version: '6' }

Expand Down Expand Up @@ -65,6 +66,9 @@ __sap_general_preconfigure_packages_x86_64:
- tuned
# package libxcrypt-compat: needed by sapstartsrv and SAP HANA on RHEL 9:
- libxcrypt-compat
# English locale packages are required as per SAP note 2369910:
- langpacks-en
- glibc-langpack-en

__sap_general_preconfigure_packages_ppc64le:
- uuidd
Expand All @@ -79,6 +83,9 @@ __sap_general_preconfigure_packages_ppc64le:
- tuned
# package libxcrypt-compat: needed by sapstartsrv and SAP HANA on RHEL 9:
- libxcrypt-compat
# English locale packages are required as per SAP note 2369910:
- langpacks-en
- glibc-langpack-en

__sap_general_preconfigure_packages_s390x:
- uuidd
Expand All @@ -93,6 +100,9 @@ __sap_general_preconfigure_packages_s390x:
- tuned
# package libxcrypt-compat: needed by sapstartsrv on RHEL 9:
- libxcrypt-compat
# English locale packages are required as per SAP note 2369910:
- langpacks-en
- glibc-langpack-en

__sap_general_preconfigure_packages: "{{ lookup('vars', '__sap_general_preconfigure_packages_' + ansible_architecture) }}"

Expand Down
2 changes: 1 addition & 1 deletion roles/sap_general_preconfigure/vars/Suse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# - SUSE Linux Enterprise Server 16

__sap_general_preconfigure_sapnotes_versions:
- ''
- { number: '2369910', version: '18' }

__sap_general_preconfigure_packages:
- uuidd
Expand Down

0 comments on commit b0f1a89

Please sign in to comment.