feat(role): sets locale for alpine correctly
This commit is contained in:
@@ -1,19 +1,63 @@
|
||||
---
|
||||
- name: Generate locales
|
||||
- name: Generate locales for Debian-based systems
|
||||
community.general.locale_gen:
|
||||
name:
|
||||
- en_US.UTF-8
|
||||
- ru_RU.UTF-8
|
||||
state: present
|
||||
when: (ansible_facts['distribution'] == "Debian") or
|
||||
(ansible_facts['distribution'] == "Ubuntu")
|
||||
|
||||
- name: Set locale
|
||||
- name: Set locale for Debian-based systems
|
||||
ansible.builtin.copy:
|
||||
dest: /etc/locale.conf
|
||||
mode: '0644'
|
||||
content: |
|
||||
LANG=en_US.UTF-8
|
||||
LC_ALL=en_US.UTF-8
|
||||
when: (ansible_facts['distribution'] == "Debian") or
|
||||
(ansible_facts['distribution'] == "Ubuntu")
|
||||
|
||||
# The same for Alpine
|
||||
- name: Install musl-locales package for Alpine
|
||||
community.general.apk:
|
||||
name: musl-locales
|
||||
state: present
|
||||
when: ansible_facts['distribution'] == "Alpine"
|
||||
|
||||
- name: Copy default locale profile to a custom override file for Alpine
|
||||
ansible.builtin.copy:
|
||||
src: /etc/profile.d/20locale.sh
|
||||
dest: /etc/profile.d/locale.sh
|
||||
remote_src: true
|
||||
mode: '0644'
|
||||
owner: root
|
||||
group: root
|
||||
force: false # Do not overwrite if the file already exists
|
||||
when: ansible_facts['distribution'] == "Alpine"
|
||||
|
||||
- name: Set LANG and LC_ALL in the custom locale file for Alpine
|
||||
ansible.builtin.lineinfile:
|
||||
path: /etc/profile.d/locale.sh
|
||||
regexp: "{{ item.regexp }}"
|
||||
line: "{{ item.line }}"
|
||||
state: present
|
||||
loop:
|
||||
- { regexp: '^export LANG=', line: 'export LANG=en_US.UTF-8' }
|
||||
- { regexp: '^export LC_ALL=', line: 'export LC_ALL=en_US.UTF-8' }
|
||||
when: ansible_facts['distribution'] == "Alpine"
|
||||
|
||||
- name: Ensure Unicode is enabled in /etc/rc.conf for Alpine
|
||||
ansible.builtin.lineinfile:
|
||||
path: /etc/rc.conf
|
||||
regexp: '^#?unicode='
|
||||
line: 'unicode="YES"'
|
||||
state: present
|
||||
when: ansible_facts['distribution'] == "Alpine"
|
||||
|
||||
|
||||
# Works fine for all
|
||||
- name: Set time
|
||||
community.general.timezone:
|
||||
name: Europe/Samara
|
||||
|
||||
|
||||
Reference in New Issue
Block a user