Skip to content

Commit

Permalink
sap_general_preconfigure: fixes for initial version of locale checkin…
Browse files Browse the repository at this point in the history
…g and setting

Fixes issue sap-linuxlab#907.

Signed-off-by: Bernd Finger <[email protected]>
  • Loading branch information
berndfinger committed Dec 3, 2024
1 parent 63657c1 commit 67b4d24
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 83 deletions.
73 changes: 19 additions & 54 deletions roles/sap_general_preconfigure/tasks/sapnote/2369910.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,84 +3,49 @@
- 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 }}): Configure RHEL 7"
(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 Languge is installed
- 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_2369910_03
- sap_general_preconfigure_configure_locale
block:
- name: Get list of installed locales
ansible.builtin.command: locale -a
changed_when: false
register: __sap_general_preconfigure_locales_installed

- name: Ensure English langpacks are available on RHEL
when: locale_list.stdout_lines | select('match', '^en_') | list | length == 0
block:
- name: Install RHEL English language packages
ansible.builtin.dnf:
name:
- langpacks-en
- glibc-langpack-en
state: present

- name: Re-Read list of installed locales
ansible.builtin.command: locale -a
changed_when: false
register: __sap_general_preconfigure_locales_installed

- name: Check if English locale is installed
- name: Assert that an English locale is installed
ansible.builtin.assert:
that:
# "'en_US.UTF-8' in __sap_general_preconfigure_locales_installed.stdout"
- locale_list.stdout_lines | select('match', '^en_') | list | length > 0
fail_msg: "No English locale installed. please install English locale"
success_msg: "English locale is installed"
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: Step 3.1 - Check if English Languge is Default locale
when: >
(sap_general_preconfigure_default_locale is undefined) or
(sap_general_preconfigure_default_locale | trim | length == 0)
tags:
- sap_general_preconfigure_2369910
- sap_general_preconfigure_2369910_03
block:
- name: Check if current default locale is English
ansible.builtin.command: grep "^LANG=en_" /etc/locale.conf
- name: Get the current default locale
ansible.builtin.command: awk '/^LANG=/&&/en_/{print}' /etc/locale.conf
changed_when: false
register: __sap_general_preconfigure_current_default_locale

- name: Assert that __sap_general_preconfigure_current_default_locale output is not empty
- 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: "No English is not set as default locale. Please set sap_general_preconfigure_default_locale variable to define an englsih default locale"
success_msg: "OK - English default locale is set"
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."

- name: Step 3.1 - Configure English Languge as Default locale
when: >
(sap_general_preconfigure_default_locale is defined) or
(sap_general_preconfigure_default_locale | trim | length > 0)
tags:
- sap_general_preconfigure_2369910
- sap_general_preconfigure_2369910_03
block:
- name: Assert that sap_general_preconfigure_default_locale starts with en
- name: Assert that the role variable sap_general_preconfigure_default_locale starts with 'en_'
ansible.builtin.assert:
that:
- sap_general_preconfigure_default_locale.startswith('en_')
fail_msg: "No Englsih locale defined in sap_general_preconfigure_default_locale"
success_msg: "OK - English default locale is valid"
that: sap_general_preconfigure_default_locale.startswith('en_')
fail_msg: "FAIL: No English locale is defined in variable 'sap_general_preconfigure_default_locale'!"
success_msg: "PASS: The English default locale is valid"

- name: Configure English locale
ansible.builtin.lineinfile:
path: /etc/locale.conf
regexp: ^LANG=
line: "LANG={{ sap_general_preconfigure_default_locale }}"
line: "LANG=\"{{ sap_general_preconfigure_default_locale }}\""
state: present
create: true
owner: root
Expand Down
34 changes: 11 additions & 23 deletions roles/sap_general_preconfigure/tasks/sapnote/assert-2369910.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
- 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 }}): Configure RHEL 7"
(version {{ (__sap_general_preconfigure_sapnotes_versions | selectattr('number', 'match', '^2369910$') | first).version }}): SAP Software on Linux: General Information"
tags:
- always

Expand All @@ -18,31 +18,19 @@
changed_when: false
register: __sap_general_preconfigure_locales_installed

- name: Ensure English langpacks are available on RHEL
when: locale_list.stdout_lines | select('match', '^en_') | list | length == 0

- name: Check if English locale is installed
- name: Assert that an English locale is installed
ansible.builtin.assert:
that:
# "'en_US.UTF-8' in __sap_general_preconfigure_locales_installed.stdout"
- locale_list.stdout_lines | select('match', '^en_') | list | length > 0
fail_msg: "FAIL: No English locale installed. please install English locale"
success_msg: "PASS: English locale is installed"
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: Step 3.1 - Check if English Languge is Default locale
tags:
- sap_general_preconfigure_2369910
- sap_general_preconfigure_2369910_03
block:
- name: Check if current default locale is English
ansible.builtin.command: grep "^LANG=en_" /etc/locale.conf
- name: Get the current default locale
ansible.builtin.command: awk '/^LANG=/&&/en_/{print}' /etc/locale.conf
changed_when: false
register: __sap_general_preconfigure_current_default_locale

- name: Assert that __sap_general_preconfigure_current_default_locale output is not empty
- 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 default locale"
success_msg: "PASS: English default locale is set"

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."
14 changes: 13 additions & 1 deletion roles/sap_general_preconfigure/vars/RedHat_7.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# vars file for sap_general_preconfigure

__sap_general_preconfigure_sapnotes_versions:
- { number: '2369910', version: '18'}
- { number: '2369910', version: '18' }
- { number: '2002167', version: '36' }
- { number: '1771258', version: '6' }
- { number: '1391070', version: '41' }
Expand Down Expand Up @@ -94,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 @@ -104,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
5 changes: 4 additions & 1 deletion roles/sap_general_preconfigure/vars/RedHat_8.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# vars file for sap_general_preconfigure

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

Expand Down Expand Up @@ -48,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
11 changes: 10 additions & 1 deletion roles/sap_general_preconfigure/vars/RedHat_8.1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# vars file for sap_general_preconfigure

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

Expand Down Expand Up @@ -50,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 @@ -60,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 @@ -68,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
11 changes: 10 additions & 1 deletion roles/sap_general_preconfigure/vars/RedHat_8.2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# vars file for sap_general_preconfigure

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

Expand Down Expand Up @@ -50,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 @@ -60,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 @@ -68,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
11 changes: 10 additions & 1 deletion roles/sap_general_preconfigure/vars/RedHat_8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# vars file for sap_general_preconfigure

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

Expand Down Expand Up @@ -60,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 @@ -71,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 @@ -80,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
11 changes: 10 additions & 1 deletion roles/sap_general_preconfigure/vars/RedHat_9.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# vars file for sap_general_preconfigure

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

Expand Down Expand Up @@ -66,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 @@ -80,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 @@ -94,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

0 comments on commit 67b4d24

Please sign in to comment.