ansible_public/playbooks/config/config_language.yaml
2022-06-14 18:53:16 +02:00

39 lines
1.5 KiB
YAML

- hosts: '{{ variable_host | default("lab15_standard") }}'
gather_facts: no
become: yes
tasks:
- name: Ensure localisation files for '{{ config_system_locale }}' are available
locale_gen:
name: "{{ config_system_locale }}"
state: present
- name: Ensure localisation files for '{{ config_system_language }}' are available
locale_gen:
name: "{{ config_system_language }}"
state: present
- 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: LANGUAGE=pl_PL.UTF-8 in /etc/default/locale
ini_file:
path: /etc/default/locale
section: null
option: LANGUAGE
value: '{{ config_system_language }}'
no_extra_spaces: yes
- name: Configure locale to '{{ config_system_locale }}' and language to '{{ config_system_language }}'
command: localectl set-locale LANG='{{ config_system_locale }}' LANGUAGE='{{ config_system_language }}'
changed_when: locale_lang != config_system_locale or locale_language != config_system_language