community.general
community.general copied to clipboard
locale_gen module cannot enable 'C' locale
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
- [X] I agree to follow the Ansible Code of Conduct
I think the problem is in this regexp: r'^(?P<locale>\S+_\S+) (?P<charset>\S+)\s*$'
https://github.com/ansible-collections/community.general/blob/8e9ec610c3749d543befc299e7c58ff782640bd1/plugins/modules/system/locale_gen.py#L71
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.
cc @AugustusKling click here for bot help
Related: #2399