mirror of
https://gitea.0xace.cc/ansible-galaxy/postgresql.git
synced 2024-11-25 00:06:42 +00:00
43 lines
2.0 KiB
YAML
43 lines
2.0 KiB
YAML
|
- name: Install glibc-all-langpacks for RedHat
|
||
|
dnf:
|
||
|
name: glibc-all-langpacks
|
||
|
state: present
|
||
|
when: ansible_facts['os_family'] == 'RedHat'
|
||
|
|
||
|
- name: Check if locale exists
|
||
|
shell: "locale -a | grep -i {{ postgresql_system_locale | regex_replace('-', '') | quote }}"
|
||
|
register: found_locale
|
||
|
changed_when: false
|
||
|
failed_when: false
|
||
|
|
||
|
- name: Create locale
|
||
|
command: "localedef -i {{ postgresql_system_locale | regex_replace('(.*)\\..*', '\\1') | quote }} -f {{ postgresql_system_locale | regex_replace('.*\\.(.*)', '\\1') | quote }} {{ postgresql_system_locale | quote }}"
|
||
|
when: not ansible_check_mode and found_locale.rc != 0
|
||
|
|
||
|
- name: Check if language exists
|
||
|
shell: "locale -a | grep -i {{ postgresql_system_language | regex_replace('-', '') | quote }}"
|
||
|
register: found_language
|
||
|
changed_when: false
|
||
|
failed_when: false
|
||
|
|
||
|
- name: Create language
|
||
|
command: "localedef -i {{ postgresql_system_language | regex_replace('(.*)\\..*', '\\1') | quote }} -f {{ postgresql_system_language | regex_replace('.*\\.(.*)', '\\1') | quote }} {{ postgresql_system_language | quote }}"
|
||
|
when: not ansible_check_mode and found_language.rc != 0
|
||
|
|
||
|
- name: Get current locale and language configuration
|
||
|
command: localectl status
|
||
|
register: locale_status
|
||
|
changed_when: false
|
||
|
|
||
|
- name: Parse 'LANG' from current locale and language configuration
|
||
|
set_fact:
|
||
|
locale_lang: "{{ locale_status.stdout | regex_search('LANG=([^\n]+)', '\\1') | first }}"
|
||
|
|
||
|
- name: Parse 'LANGUAGE' from current locale and language configuration
|
||
|
set_fact:
|
||
|
locale_language: "{{ locale_status.stdout | regex_search('LANGUAGE=([^\n]+)', '\\1') | default([locale_lang], true) | first }}"
|
||
|
|
||
|
- name: Configure locale to '{{ postgresql_system_locale }}' and language to '{{ postgresql_system_language }}'
|
||
|
command: localectl set-locale LANG={{ postgresql_system_locale }} LANGUAGE={{ postgresql_system_language }}
|
||
|
changed_when: locale_lang != postgresql_system_locale or locale_language != postgresql_system_language
|