Skip to content

Commit

Permalink
default locale was not set when non-english locale was default
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus Koch committed Dec 20, 2024
1 parent de5988f commit 6715920
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
25 changes: 12 additions & 13 deletions roles/sap_general_preconfigure/tasks/sapnote/2369910.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,11 @@
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 '/^LANG=/&&(/C.UTF-8/||/en_/){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."

# Optimization: Check if defined locale is installed, valid and English.
# This code currently allows an invalid locale such as 'en_XY.UTF-74'
- name: Configure English locale
when:
- sap_general_preconfigure_default_locale is defined
- sap_general_preconfigure_default_locale | length > 0
- __sap_general_preconfigure_locales_installed.stdout_lines | select('match', sap_general_preconfigure_default_locale) | list | length > 0
- sap_general_preconfigure_default_locale.startswith('en_') or sap_general_preconfigure_default_locale.startswith('C.UTF-8')
ansible.builtin.lineinfile:
path: /etc/locale.conf
Expand All @@ -51,3 +39,14 @@
owner: root
group: root
mode: '0644'

- name: Get the current default locale
ansible.builtin.command: awk '/^LANG=/&&(/C.UTF-8/||/en_/){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."
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'}
- '' # { number: '2369910', version: '18'}

__sap_general_preconfigure_packages:
- uuidd
Expand Down

0 comments on commit 6715920

Please sign in to comment.