Bug#955733: cloud-init does not set locale specified in user data
On Wed, Jun 28, 2023 at 08:51:46PM -0700, Noah Meyerhans wrote:
> I think that each of the components is working correct if viewed in
> isolation, but the end result is not what you expect. If we document
> that you must first populate /etc/locale.gen with the desired list of
> available locales, that may be sufficient. For example, the following
> sets the desired locale:
>
> admin@ip-10-0-3-7:~$ sudo cat /var/lib/cloud/instance/user-data.txt
> #cloud-config
> write_files:
> - path: /etc/locale.gen
> content: ZW5fR0IuVVRGLTggVVRGLTgK
> encoding: base64
> locale: en_GB.UTF-8
> admin@ip-10-0-3-7:~$ echo "ZW5fR0IuVVRGLTggVVRGLTgK" | openssl base64 -d
> en_GB.UTF-8 UTF-8
This feels like a workaround for the failure of cloud-init setting the locale
on a Debian install.
The locale configuration in cloud-init is expecting locale-gen to configure the
generated locales with the specified locale.
https://git.launchpad.net/ubuntu/+source/cloud-init/tree/cloudinit/distros/debian.py#n401
Debian just ignores the locale passed as a parameter.
> Do Ubuntu systems list all known locales in /etc/locale.gen? That would
> make the locale module work without additional configuration, but seems
> unnecessarily expensive.
Ubuntu does not list all locales in /etc/locale.gen, but their version of
locale-gen will update /etc/locale.gen to add/uncomment the specified locale
before generating locales.
https://git.launchpad.net/ubuntu/+source/glibc/tree/debian/local/usr_sbin/locale-gen?h=ubuntu/jammy#n115
It seems cloud-init has expectation on what locale-gen will do (i.e. _update_
and generate), and that is not the case.
I don't know if cloud-init should take on the responsibility for updating
/etc/locale.gen, or if locale-gen should update /etc/locale.gen if passed a
parameter.
Reply to: