Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

locale_gen doesn't work on Gentoo targets if a specified locale doesn't exist in /etc/locale.gen #2399

Open
1 task done
myrdd opened this issue May 1, 2021 · 9 comments
Labels
bug This issue/PR relates to a bug module module plugins plugin (any type) python3 system

Comments

@myrdd
Copy link

myrdd commented May 1, 2021

Summary

The module locale_gen fails with the following message:
The locale you've entered is not available on your system.

This issue has been discussed here: ansible/ansible#38931
There was a PR here: ansible/ansible#34146

Citing @s-hamann:

Not having all available locales in /etc/locale.gen is normal on Gentoo. On a fresh install, it contains 14 commented examples and the administrator is expected to add or uncomment their desired locales.
Gentoo has /usr/share/i18n/SUPPORTED.

locale_gen is looking inside /etc/locale.gen for valid locales, but for Gentoo it should look inside /usr/share/i18n/SUPPORTED.

Issue Type

Bug Report

Component Name

locale_gen

Ansible Version

I don't use the most recent version of Ansible, but I've read the most recent locale_gen code and there's no case for Gentoo.

$ ./.venv/bin/ansible --version
ansible 2.9.7
  config file = /home/myself/ansible/ansible.cfg
  configured module search path = ['/home/myself/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/myself/ansible/.venv/lib/python3.7/site-packages/ansible
  executable location = ./.venv/bin/ansible
  python version = 3.7.3 (default, Jan 22 2021, 20:04:44) [GCC 8.3.0]

Configuration

$ ./.venv/bin/ansible-config dump --only-changed
DEFAULT_HOST_LIST(/home/myself/ansible/ansible.cfg) = ['/home/myself/ansible/hosts.yml']
DEFAULT_STDOUT_CALLBACK(/home/myself/ansible/ansible.cfg) = debug
INTERPRETER_PYTHON(/home/myself/ansible/ansible.cfg) = auto
INVENTORY_ENABLED(/home/myself/ansible/ansible.cfg) = ['host_list', 'yaml']

OS / Environment

target OS: Gentoo

/usr/share/i18n/SUPPORTED on Gentoo

/etc/locale.gen on Gentoo:

# /etc/locale.gen: list all of the locales you want to have on your system.
# See the locale.gen(5) man page for more details.
#
# The format of each line:
# <locale name> <charset>
#
# Where <locale name> starts with a name as found in /usr/share/i18n/locales/.
# It must be unique in the file as it is used as the key to locale variables.
# For non-default encodings, the <charset> is typically appended.
#
# Where <charset> is a charset located in /usr/share/i18n/charmaps/ (sans any
# suffix like ".gz").
#
# All blank lines and lines starting with # are ignored.
#
# For the default list of supported combinations, see the file:
# /usr/share/i18n/SUPPORTED
#
# Whenever glibc is emerged, the locales listed here will be automatically
# rebuilt for you.  After updating this file, you can simply run `locale-gen`
# yourself instead of re-emerging glibc.

#en_US ISO-8859-1
#en_US.UTF-8 UTF-8
#ja_JP.EUC-JP EUC-JP
#ja_JP.UTF-8 UTF-8
#ja_JP EUC-JP
#en_HK ISO-8859-1
#en_PH ISO-8859-1
#de_DE ISO-8859-1
#de_DE@euro ISO-8859-15
#es_MX ISO-8859-1
#fa_IR UTF-8
#fr_FR ISO-8859-1
#fr_FR@euro ISO-8859-15
#it_IT ISO-8859-1

Steps to Reproduce

- name: generate locales
  locale_gen:
    name: '{{ item }}'
    state: present
  loop:
    - de_DE.UTF-8
    - en_US.UTF-8

Expected Results

de_DE.UTF-8 should be added to /etc/locale.gen if it exists in /usr/share/i18n/SUPPORTED.

Actual Results

PLAY [all] ****************************************************************************************************

TASK [Gathering Facts] ****************************************************************************************
ok: [gentoo.mynet.localhost]

TASK [common : generate locales] ******************************************************************************
failed: [gentoo.mynet.localhost] (item=de_DE.UTF-8) => {
    "ansible_loop_var": "item",
    "changed": false,
    "item": "de_DE.UTF-8"
}

MSG:

The locale you've entered is not available on your system.
ok: [gentoo.mynet.localhost] => (item=en_US.UTF-8)

PLAY RECAP ****************************************************************************************************
gentoo.mynet.localhost : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@ansibullbot
Copy link
Collaborator

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added affects_2.9 bug This issue/PR relates to a bug module module needs_triage plugins plugin (any type) python3 system labels May 1, 2021
@myrdd myrdd changed the title locale_gen doesn't support Gentoo targets locale_gen doesn't support Gentoo targets if the specified locales don't exist in /etc/locale.gen May 1, 2021
@myrdd myrdd changed the title locale_gen doesn't support Gentoo targets if the specified locales don't exist in /etc/locale.gen locale_gen doesn't support Gentoo targets if the specified locales don't exist in /etc/locale.gen May 1, 2021
@myrdd myrdd changed the title locale_gen doesn't support Gentoo targets if the specified locales don't exist in /etc/locale.gen locale_gen doesn't work on Gentoo targets if a specified locale don't exist in /etc/locale.gen May 1, 2021
@aminvakil
Copy link
Contributor

As it's been stated in the PR you have mentioned and these lines:

def is_available(name, ubuntuMode):
"""Check if the given locale is available on the system. This is done by
checking either :
* if the locale is present in /etc/locales.gen
* or if the locale is present in /usr/share/i18n/SUPPORTED"""
if ubuntuMode:
__regexp = r'^(?P<locale>\S+_\S+) (?P<charset>\S+)\s*$'
__locales_available = '/usr/share/i18n/SUPPORTED'
else:
__regexp = r'^#{0,1}\s*(?P<locale>\S+_\S+) (?P<charset>\S+)\s*$'
__locales_available = '/etc/locale.gen'

It's checking /usr/share/i18n/SUPPORTED in some circumstances, but I'm not sure if just changing it to also check /usr/share/i18n/SUPPORTED is fine or not as I don't have this file on my system (Arch Linux).

@felixfontein
Copy link
Collaborator

Maybe the best behavior would be to first check /etc/locale.gen (if not in "Ubuntu mode"), and if it is not found there and /usr/share/i18n/SUPPORTED also exists, also check that one. I don't have /usr/share/i18n/SUPPORTED on my Arch boxes, but it exists on some Debian boxes I checked.

@aminvakil
Copy link
Contributor

FYI it's also not available on CentOS 7, 8.

@myrdd
Copy link
Author

myrdd commented May 1, 2021

FYI: on Debian, /usr/share/i18n/SUPPORTED is part of the locales package, which also contains the locale-gen binary:
https://packages.debian.org/buster/locales
https://packages.debian.org/buster/all/locales/filelist

@myrdd myrdd changed the title locale_gen doesn't work on Gentoo targets if a specified locale don't exist in /etc/locale.gen locale_gen doesn't work on Gentoo targets if a specified locale doesn't exist in /etc/locale.gen Oct 3, 2021
@ansibullbot
Copy link
Collaborator

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

@martin-braun
Copy link

martin-braun commented Jul 24, 2024

Originates from ansible/ansible-modules-extras#425 and is still an issue on a fresh Debian bookworm.

Deleting the locale.gen doesn't work and isn't recommend.

I stumbled over this, because a lot of African locales are missing. You have to pick the origin locale of the country that occupied their land in the past. I.e. fr_FR instead of fr_CF, etc.

@felixfontein
Copy link
Collaborator

Arch has /usr/share/i18n/SUPPORTED nowadays as well (reacting to my comment from 2021).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug module module plugins plugin (any type) python3 system
Projects
None yet
Development

No branches or pull requests

5 participants