Skip to content

Commit eafcc87

Browse files
committed
base_image: use guest OS detection for Debian-specific packages
The virt-builder template was using the distro_debian_based variable to determine which packages to install in guest images, but this variable reflects the host OS rather than the guest OS. This caused installation failures when creating Fedora guests from a Debian host, as the template attempted to install Debian-specific packages like isc-dhcp-client and ifupdown on Fedora systems where they don't exist. Replace the host OS check with proper guest OS detection using the virtbuilder_os_version variable, which contains the actual guest OS name like "fedora-41" or "debian-13". This ensures Debian-specific networking packages and configuration only apply to Debian and Ubuntu guests regardless of the host operating system. Additionally, consolidate locale configuration by moving it from the trixie-specific block to the general Debian block. This ensures all Debian-based guests get proper locale setup during image build, not just Debian Trixie. The locale commands (locale-gen, update-locale) are Debian-specific and safe to run during virt-builder image creation for any Debian-based distribution. This change enables creation of fedora-41 guests from debian hosts without package installation failures or incorrect network configuration. Link: https://lore.kernel.org/all/[email protected]/ [1] Fixes: 9822799 ("devconfig: drop locales-all leftovers") Reported-by: Chuck Lever <[email protected]> Generated-by: Claude AI Signed-off-by: Daniel Gomez <[email protected]>
1 parent ce060d3 commit eafcc87

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ root-password password:kdevops
2929
sm-unregister
3030
{% endif %}
3131

32-
{% if distro_debian_based is defined and distro_debian_based %}
32+
{% if virtbuilder_os_version is defined and ('debian' in virtbuilder_os_version or 'ubuntu' in virtbuilder_os_version) %}
3333
{# Ugh, debian has to be told to bring up the network and regenerate ssh keys #}
3434
{# Hope we get that interface name right! #}
3535
install isc-dhcp-client,ifupdown
@@ -43,6 +43,13 @@ firstboot-command DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=tru
4343
firstboot-command systemctl start ssh
4444
firstboot-command apt update && apt upgrade --yes
4545
uninstall unattended-upgrades
46+
write /etc/default/locale:LANG=en_US.UTF-8
47+
append-line /etc/default/locale:LANGUAGE=en_US:en
48+
write /etc/locale.gen:en_US.UTF-8 UTF-8
49+
run-command locale-gen en_US.UTF-8
50+
run-command update-locale LANG=en_US.UTF-8
51+
firstboot-command locale-gen en_US.UTF-8
52+
firstboot-command update-locale LANG=en_US.UTF-8
4653

4754
{% if distro_debian_trixie is defined and distro_debian_trixie %}
4855
{# CONFIG_GUESTFS_COPY_SOURCES_FROM_HOST_TO_GUEST will not work #}
@@ -67,13 +74,6 @@ append-line /etc/nsswitch.conf:ethers: db files
6774
append-line /etc/nsswitch.conf:rpc: db files
6875
append-line /etc/nsswitch.conf:netgroup: nis
6976
uninstall cloud-init
70-
write /etc/default/locale:LANG=en_US.UTF-8
71-
append-line /etc/default/locale:LANGUAGE=en_US:en
72-
write /etc/locale.gen:en_US.UTF-8 UTF-8
73-
run-command locale-gen en_US.UTF-8
74-
run-command update-locale LANG=en_US.UTF-8
75-
firstboot-command locale-gen en_US.UTF-8
76-
firstboot-command update-locale LANG=en_US.UTF-8
7777
firstboot-command systemctl stop ssh
7878
firstboot-command systemctl start ssh
7979

0 commit comments

Comments
 (0)