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 module cannot enable 'C' locale #5142

Closed
1 task done
vuzdemav opened this issue Aug 22, 2022 · 4 comments · Fixed by #6774
Closed
1 task done

locale_gen module cannot enable 'C' locale #5142

vuzdemav opened this issue Aug 22, 2022 · 4 comments · Fixed by #6774
Labels
bug This issue/PR relates to a bug module module plugins plugin (any type) system

Comments

@vuzdemav
Copy link

Summary

When I try to ensure that the "C.UTF-8" locale is enabled, the locale-gen module says that "The locale you've entered is not available on your system." even though it is present in /etc/locale.gen

Issue Type

Bug Report

Component Name

locale_gen

Ansible Version

$ ansible --version
ansible [core 2.12.3]
  config file = /home/ckerr/repos/ansible-base/ansible.cfg
  configured module search path = ['/home/ckerr/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/ckerr/.venvs/ansible/lib/python3.10/site-packages/ansible
  ansible collection location = /home/ckerr/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/ckerr/.venvs/ansible/bin/ansible
  python version = 3.10.4 (main, Jun 29 2022, 12:14:53) [GCC 11.2.0]
  jinja version = 3.1.1
  libyaml = True

Community.general Version

$ ansible-galaxy collection list community.general
[DEPRECATION WARNING]: [defaults]callback_whitelist option, normalizing names to new standard, use callbacks_enabled instead. This feature will be removed from ansible-
core in version 2.15. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.

# /home/ckerr/.venvs/ansible/lib/python3.10/site-packages/ansible_collections
Collection        Version
----------------- -------
community.general 4.6.0  

# /home/ckerr/.ansible/collections/ansible_collections
Collection        Version
----------------- -------
community.general 2.3.0  

Configuration

- name: "Set up locales"
  community.general.locale_gen:
    name: 'C.UTF-8'
    state: present

OS / Environment

Ubuntu 22.04 (For some reason the target host does not have /var/lib/locales/supported.d as is normal for Ubuntu. However, other locales work so the problem is with C.UTF-8)

Steps to Reproduce

- name: "Set up locales"
  community.general.locale_gen:
    name: 'C.UTF-8'
    state: present

Expected Results

C locale is enabled (or nothing happens if it is already enabled)

Actual Results

failed: [kvm31-dev-ksp-ee] (item=C.UTF-8) => {
    "ansible_loop_var": "item",
    "changed": false,
    "invocation": {
        "module_args": {
            "name": "C.UTF-8",
            "state": "present"
        }
    },
    "item": "C.UTF-8",
    "msg": "The locale you've entered is not available on your system."
}

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@vuzdemav
Copy link
Author

I think the problem is in this regexp: r'^(?P<locale>\S+_\S+) (?P<charset>\S+)\s*$'

__regexp = r'^(?P<locale>\S+_\S+) (?P<charset>\S+)\s*$'

It assumes that the locale name has an underscore. This is not the case for C.UTF-8 and eo.UTF-8, possibly also for others.

@ansibullbot
Copy link
Collaborator

@ansibullbot ansibullbot added bug This issue/PR relates to a bug module module plugins plugin (any type) system labels Aug 22, 2022
@vuzdemav
Copy link
Author

Related: #2399

@russoz
Copy link
Collaborator

russoz commented Jun 23, 2023

It assumes that the locale name has an underscore. This is not the case for C.UTF-8 and eo.UTF-8, possibly also for others.

Apparently we have eo and eo_US.UTF-8, but no eo.UTF-8 available in Ubuntu 22.04:

vagrant@ubuntu-jammy:~$ grep '^eo' /usr/share/i18n/SUPPORTED
eo UTF-8
eo_US.UTF-8 UTF-8

I am working on this, but locale_gen module removes locales by commenting out the corresponding line in /etc/locale.gen, and I will have to create a special case in the test for C.UTF-8 as it is the fallback locale and even with the line commented out it never ceases to be available. Which begs the question: why would you need to add something that is supposed to be always there?

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) system
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants