Skip to content

Commit 2514a69

Browse files
committed
guestfs: fix locale warnings in VM deployments
Fix "cannot change locale" SSH warnings by configuring locales comprehensively across both new and existing VM deployments. New VMs (virt-builder template): - Add locales-all package for comprehensive locale support - Configure en_US.UTF-8 during both image build and first boot - Remove problematic dpkg-reconfigure command Existing VMs (devconfig tasks): - 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 This ensures en_US.UTF-8 locale is available at boot, eliminating SSH warnings across all VM deployment scenarios. Generated-by: Claude AI Link: https://lore.kernel.org/r/20250820-guestfs-custom-image-fixes-v1-9-0fe1d69c3f33@samsung.com Signed-off-by: Daniel Gomez <[email protected]> Reviewed-by: Chuck Lever <[email protected]>
1 parent e46bf3c commit 2514a69

File tree

2 files changed

+45
-2
lines changed

2 files changed

+45
-2
lines changed

playbooks/roles/base_image/templates/virt-builder.j2

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ mkdir {{ target_dir }}
1111
copy-in {{ guestfs_distro_source_and_dest_file }}:{{ target_dir }}
1212
{% endif %}
1313

14-
install sudo,qemu-guest-agent,python3,bash
14+
install sudo,qemu-guest-agent,python3,bash,locales-all
1515
run-command useradd {{ kdevops_uid }} -s /bin/bash -m kdevops
1616
append-line /etc/sudoers.d/kdevops:kdevops ALL=(ALL) NOPASSWD: ALL
1717
edit /etc/default/grub:s/^GRUB_CMDLINE_LINUX_DEFAULT=.*/GRUB_CMDLINE_LINUX_DEFAULT="console=ttyS0"/
@@ -63,9 +63,10 @@ uninstall cloud-init
6363
write /etc/default/locale:LANG=en_US.UTF-8
6464
append-line /etc/default/locale:LANGUAGE=en_US:en
6565
write /etc/locale.gen:en_US.UTF-8 UTF-8
66+
run-command locale-gen en_US.UTF-8
67+
run-command update-locale LANG=en_US.UTF-8
6668
firstboot-command locale-gen en_US.UTF-8
6769
firstboot-command update-locale LANG=en_US.UTF-8
68-
firstboot-command DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true dpkg-reconfigure -p low --force locales
6970
firstboot-command systemctl stop ssh
7071
firstboot-command systemctl start ssh
7172

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)