-
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
Open
rhmk
wants to merge
13
commits into
sap-linuxlab:dev
Choose a base branch
from
mk-ansible-roles:issue-907
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
b28bb87
Update requirements-workflow.txt on Sun Dec 1 07:23:56 UTC 2024
cb9b5f7
Merge branch 'dev' into automation/dependencies_update
rhmk c8909a7
Merge pull request #4 from mk-ansible-roles/automation/dependencies_u…
rhmk 7c8d698
Implementing SAP Note 2369910 - locale
63657c1
Merge pull request #5 from sap-linuxlab/main
rhmk 67b4d24
sap_general_preconfigure: fixes for initial version of locale checkin…
berndfinger 9983137
sap-general-preconfigure: try to fix PR
89ae64f
Merge branch 'dev' into issue-907
7ffeded
Lint fixes for PR
3ac2d7e
made requested changes for C.UTF-8 locale
de5988f
typo in arguments.specs gefixt
6715920
default locale was not set when non-english locale was default
c0d9e33
change because locale -a always creates *.utf8
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# 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: 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 | ||
regexp: ^LANG= | ||
line: "LANG=\"{{ sap_general_preconfigure_default_locale }}\"" | ||
state: present | ||
create: true | ||
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." |
36 changes: 36 additions & 0 deletions
36
roles/sap_general_preconfigure/tasks/sapnote/assert-2369910.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 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
UTF-8
orutf8
notation (the output oflocale -a
contains onlyutf8
on RHEL 8 and RHEL 9) and also avoids setting an unsupported locale.If there is an SAP supported OS which has
UTF-8
in the output oflocale -a
, we could of course add theregex_replace
filter also after__sap_general_preconfigure_locales_installed.stdout_lines
.