Package: cloud.debian.org Followup-For: Bug #1107636 X-Debbugs-Cc: neit...@archlinux.org
Indeed, getting the desired locale to work properly is a pretty annoying aspect of Debian cloud images. >From your suggestion I thought of using `locale_configfile: /etc/locale.conf` >from [1], but it didn't work: ``` $ cat /var/log/cloud-init.log | grep locale 2025-06-17 12:51:01,492 - subp.py[DEBUG]: Running command ['localectl', 'set-x11-keymap', 'fr', 'pc105', '', ''] with allowed return codes [0] (shell=False, capture=True) 2025-06-17 12:51:01,548 - modules.py[DEBUG]: Running module locale (<module 'cloudinit.config.cc_locale' from '/usr/lib/python3/dist-packages/cloudinit/config/cc_locale.py'>) with frequency once-per-instance 2025-06-17 12:51:01,548 - handlers.py[DEBUG]: start: modules-config/config-locale: running config-locale with frequency once-per-instance 2025-06-17 12:51:01,548 - util.py[DEBUG]: Writing to /var/lib/cloud/instances/iid-local01/sem/config_locale - wb: [644] 24 bytes 2025-06-17 12:51:01,548 - helpers.py[DEBUG]: Running config-locale using lock (<FileLock using file '/var/lib/cloud/instances/iid-local01/sem/config_locale'>) 2025-06-17 12:51:01,548 - util.py[DEBUG]: Reading from /etc/default/locale (quiet=False) 2025-06-17 12:51:01,548 - util.py[DEBUG]: Read 13 bytes from /etc/default/locale 2025-06-17 12:51:01,548 - cc_locale.py[DEBUG]: Setting locale to fr_FR.UTF-8 2025-06-17 12:51:01,548 - debian.py[DEBUG]: Generating locales for fr_FR.UTF-8 2025-06-17 12:51:01,548 - subp.py[DEBUG]: Running command ['locale-gen', 'fr_FR.UTF-8'] with allowed return codes [0] (shell=False, capture=False) 2025-06-17 12:51:01,553 - debian.py[DEBUG]: Updating /etc/locale.conf with locale setting LANG=fr_FR.UTF-8 2025-06-17 12:51:01,553 - subp.py[DEBUG]: Running command ['update-locale', '--locale-file=/etc/locale.conf', 'LANG=fr_FR.UTF-8'] with allowed return codes [0] (shell=False, capture=False) 2025-06-17 12:51:01,567 - handlers.py[DEBUG]: finish: modules-config/config-locale: FAIL: running config-locale with frequency once-per-instance 2025-06-17 12:51:01,567 - util.py[WARNING]: Running module locale (<module 'cloudinit.config.cc_locale' from '/usr/lib/python3/dist-packages/cloudinit/config/cc_locale.py'>) failed 2025-06-17 12:51:01,567 - util.py[DEBUG]: Running module locale (<module 'cloudinit.config.cc_locale' from '/usr/lib/python3/dist-packages/cloudinit/config/cc_locale.py'>) failed File "/usr/lib/python3/dist-packages/cloudinit/config/cc_locale.py", line 70, in handle cloud.distro.apply_locale(locale, locale_cfgfile) File "/usr/lib/python3/dist-packages/cloudinit/distros/debian.py", line 132, in apply_locale update_locale_conf(locale, out_fn, keyname=keyname) File "/usr/lib/python3/dist-packages/cloudinit/distros/debian.py", line 374, in update_locale_conf Command: ['update-locale', '--locale-file=/etc/locale.conf', 'LANG=fr_FR.UTF-8'] ``` Indeed, it doesn't exist in the version of cloud-init used in Debian Bookworm[2]. Currently the best workaround I've found[0] is to configure the following in `user-data.yaml` : ```yaml locale: fr_FR.UTF-8 bootcmd: - cloud-init-per once setlocales sed -i '/fr_FR.UTF/s/^# //' /etc/locale.gen ``` This allows the regular locale-setting process to work out of the box : ``` debian@debcloud:~$ localectl System Locale: LANG=fr_FR.UTF-8 (...) debian@debcloud:~$ cat /etc/default/locale LANG=fr_FR.UTF-8 debian@debcloud:~$ locale LANG=fr_FR.UTF-8 LANGUAGE= LC_CTYPE="fr_FR.UTF-8" LC_NUMERIC="fr_FR.UTF-8" LC_TIME="fr_FR.UTF-8" LC_COLLATE="fr_FR.UTF-8" LC_MONETARY="fr_FR.UTF-8" LC_MESSAGES="fr_FR.UTF-8" LC_PAPER="fr_FR.UTF-8" LC_NAME="fr_FR.UTF-8" LC_ADDRESS="fr_FR.UTF-8" LC_TELEPHONE="fr_FR.UTF-8" LC_MEASUREMENT="fr_FR.UTF-8" LC_IDENTIFICATION="fr_FR.UTF-8" LC_ALL= ``` After that, there is the related issue of getting the virtual console keymap to match the `keyboard:` config, which requires the `console-setup` package to be installed (bug report impending). See also cloud-init bug #4195[3]. Cheers, [0]: based upon https://old.reddit.com/r/devops/comments/1gjo37e/cloudinit_am_i_setting_wrong_my_locale_config/lvfmxsf/ [1]: https://cloudinit.readthedocs.io/en/latest/reference/yaml_examples/locale_and_timezone.html#set-the-locale-via-config-file [2]: https://cloudinit.readthedocs.io/en/22.4.2/reference/yaml_examples/locale_and_timezone.html [3]: https://github.com/canonical/cloud-init/issues/4195