Bug#955733: cloud-init does not set locale specified in user data
On Sat, Apr 04, 2020 at 11:49:42AM +0100, Nick Holloway wrote:
> Package: cloud-init
> Version: 18.3-6
Confirmed that the behavior as described is still an issue in cloud-init
22.4.2-1 in bookworm.
> The command "locale-gen" does not accept a locale as an argument, but
> only generates the locales listed in "/etc/locale.gen". So the locale
> requested does not get generated, and causes the subsequent failure when
> setting locale.
>
> 2020-04-04 10:00:43,196 - util.py[DEBUG]: Running command ['update-locale', '--locale-file=/etc/default/locale', 'LANG=en_GB.UTF-8'] with allowed return codes [0] (shell=False, capture=False)
>
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
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.
noah
Reply to: