Skip to content

Commit

Permalink
Fix locales on Ubuntu
Browse files Browse the repository at this point in the history
The new Ubuntu base image we use does not ship with any locales
or locale configuration. A fix[1] attempted to remedy this by
copying the default locale configuration from the host, but it
is not a valid fix since the locale from the host is not present
or generated in the container cache. This causes things to break
on the system when valid locales are used, such as database
systems[2].

Instead, to prepare locales in Ubuntu[3], we should install the
locales package and provide a list of valid locales to prep
the base image. It is not necessary to copy /etc/default/locale
from the system. The first locale provided will be used as
the system's base locale by running 'update-locale' which
builds /etc/default/locale.

[1] e62de97
[2] http://paste.openstack.org/show/719241/
[3] https://www.thomas-krenn.com/en/wiki/Configure_Locales_in_Ubuntu#No_locale_set

Change-Id: Iaa5351777d7db464e8a897fdf33c0f440bfa601b
  • Loading branch information
logan2211 committed Apr 14, 2018
1 parent 1871fbe commit 9ad190a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
4 changes: 4 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,10 @@ lxc_cache_download_template_options: >-
--variant {{ lxc_cache_default_variant }}
{{ lxc_cache_download_template_extra_options }}
# Locales to populate in the LXC base cache
lxc_cache_locales:
- en_US.UTF-8

# LXC must be installed from a COPR repository on CentOS 7 since the version
# provided in EPEL is much too old (1.x).
lxc_centos_package_baseurl: https://copr-be.cloud.fedoraproject.org/results/thm/lxc2.0/epel-7-x86_64/
Expand Down
7 changes: 7 additions & 0 deletions templates/prep-scripts/ubuntu_16_prep.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ for action in disable mask; do
systemctl ${action} systemd-networkd-resolvconf-update.service || true
done

{% for locale in lxc_cache_locales %}
locale-gen {{ locale }}
{% if loop.first | bool %}
update-locale LANG={{ locale }}
{% endif %}
{% endfor %}

# Set the IP of the lxcbr0 interface as the DNS server
echo "nameserver {{ lxc_net_address }}" > /etc/resolv.conf
systemctl enable systemd-networkd
Expand Down
5 changes: 2 additions & 3 deletions vars/ubuntu-16.04.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ _lxc_cache_map:
- /etc/apt/sources.list
- /etc/apt/apt.conf.d/
- /etc/apt/preferences.d/
- /etc/default/locale
- /etc/environment
- /etc/localtime
- /etc/locale.conf
- /root/repo.keys
- /etc/protocols

Expand All @@ -37,11 +35,13 @@ _lxc_cache_distro_packages:
- ca-certificates
- cron # xenial doesn't have cronie
- dbus
- debianutils # for 'which' executable
- gcc
- iproute2
- iputils-ping
- libffi-dev
- libssl-dev
- locales
- netbase
- openssh-server
- openssl
Expand All @@ -54,4 +54,3 @@ _lxc_cache_distro_packages:
- systemd-sysv
- tar
- wget
- debianutils # for 'which' executable

0 comments on commit 9ad190a

Please sign in to comment.