Skip to content

Commit 5fcc3ce

Browse files
committed
devconfig: fix locale configuration on existing VMs
Add locale configuration tasks to firstconfig to ensure existing VMs have correct locales, complementing the base image template fixes. This ensures en_US.UTF-8 locale is properly configured on: - New VMs: fixed during image creation (virt-builder template) - Existing VMs: fixed during firstconfig (this commit) Changes: - Install locales-all package if missing - Configure /etc/default/locale and /etc/locale.gen files - Generate and update locales with locale-gen and update-locale Runs early with firstconfig tag for immediate fix during VM setup. Generated-by: Claude AI Signed-off-by: Daniel Gomez <[email protected]>
1 parent 98c0dac commit 5fcc3ce

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

playbooks/roles/devconfig/tasks/main.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,48 @@
2929
dest: /etc/hostname
3030
tags: hostname
3131

32+
- name: Ensure locales-all package is installed
33+
become: true
34+
become_flags: 'su - -c'
35+
become_method: sudo
36+
ansible.builtin.package:
37+
name: locales-all
38+
state: present
39+
when:
40+
- ansible_facts['os_family']|lower == 'debian'
41+
tags: firstconfig
42+
43+
- name: Configure en_US.UTF-8 locale files
44+
become: true
45+
become_flags: 'su - -c'
46+
become_method: sudo
47+
ansible.builtin.lineinfile:
48+
path: "{{ item.path }}"
49+
line: "{{ item.line }}"
50+
create: true
51+
mode: '0644'
52+
owner: root
53+
group: root
54+
loop:
55+
- { path: '/etc/default/locale', line: 'LANG=en_US.UTF-8' }
56+
- { path: '/etc/default/locale', line: 'LANGUAGE=en_US:en' }
57+
- { path: '/etc/locale.gen', line: 'en_US.UTF-8 UTF-8' }
58+
when:
59+
- ansible_facts['os_family']|lower == 'debian'
60+
tags: firstconfig
61+
62+
- name: Generate and update locales
63+
become: true
64+
become_flags: 'su - -c'
65+
become_method: sudo
66+
ansible.builtin.shell: |
67+
locale-gen en_US.UTF-8
68+
update-locale LANG=en_US.UTF-8
69+
changed_when: true
70+
when:
71+
- ansible_facts['os_family']|lower == 'debian'
72+
tags: firstconfig
73+
3274
# Distro specific
3375

3476
# Check and fix APT mirrors for Debian testing before installing dependencies

0 commit comments

Comments
 (0)