-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sap_general_preconfigure - Checking for english locales, issue 907 #914
base: dev
Are you sure you want to change the base?
Changes from 10 commits
b28bb87
cb9b5f7
c8909a7
7c8d698
63657c1
67b4d24
9983137
89ae64f
7ffeded
3ac2d7e
de5988f
6715920
c0d9e33
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# 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: 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 '/^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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tested and now suggest to use the following code (including the comments to explain the logic a bit):
It allows for setting an English locale using either the If there is an SAP supported OS which has |
||
when: | ||
- sap_general_preconfigure_default_locale is defined | ||
- sap_general_preconfigure_default_locale | 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 | ||
regexp: ^LANG= | ||
line: "LANG=\"{{ sap_general_preconfigure_default_locale }}\"" | ||
state: present | ||
create: true | ||
owner: root | ||
group: root | ||
mode: '0644' |
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 '/^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 a valid English default locale with the variable 'sap_general_preconfigure_default_locale' !" | ||
success_msg: "PASS: An English default locale is set." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am guessing you mean:
sap_general_preconfigure_default_locale: 'en_US.UTF-8' -- or C.UTF-8 depending what you think should be the "default" recommendation :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Klaas- fixed this one, in addition @berndfinger and I found a bug in the algorithm so that this was variable was never used in certain circumstances (non-English locale set as default would always stop although variable was set)
This variable above is just an example, per default nothing is changed (variable empty in defaults/main.yml)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also removed the code from being executed on SLES because the reviewers are not available for the next weeks -- We may need to open another PR to enable this on SLES