community.general
community.general copied to clipboard
dnf_config_manager: doesn't work when the locale of the remote_user is not english
Summary
When executing dnf_config_manager
with a remote user that has a locale not set to english (tested with LANG=fr_FR.UTF-8
) the module fails with did not find repo with ID 'xxx' in dnf repolist --all --verbose
.
The module uses a regex on the dnf repolist --all --verbose
command output defined here : https://github.com/ansible-collections/community.general/blob/cc72fa078694872a8884f2f52e4e425ae35f3745/plugins/modules/dnf_config_manager.py#L130
But the dnf repolist --all --verbose
command output is localized so if the ansible remote_user
has its locale set to something other than english or C, instead of having this in the output :
Repo-id : crb
Repo-name : CentOS Stream 9 - CRB
Repo-status : enabled
Repo-revision : 9-stream
Repo-updated : Fri Oct 18 12:00:53 2024
Repo-pkgs : 4533
Repo-available-pkgs: 4530
Repo-size : 40 G
Repo-mirrors : https://mirrors.centos.org/metalink?repo=centos-crb-9-stream&arch=x86_64&protocol=https,http
Repo-baseurl : http://mirror.in2p3.fr/pub/linux/centos-stream/9-stream/CRB/x86_64/os/ (94 more)
Repo-expire : 21600 second(s) (last: Mon Oct 21 15:21:37 2024)
Repo-filename : /etc/yum.repos.d/centos.repo
there's this (user with LANG=fr_FR.UTF-8
used as example) :
Id du dépôt : crb
Nom du dépôt : CentOS Stream 9 - CRB
État du dépôt : activé
Révision du dépôt : 9-stream
Dépôt mis à jour: mer. 16 oct. 2024 15:46:24
Paquets du dépôt : 4533
Paquets dispo. : 4530
Taille du dépôt : 40 G
Métalien du dépôt : https://mirrors.centos.org/metalink?repo=centos-crb-9-stream&arch=x86_64&protocol=https,http
Mis à jour : lun. 21 oct. 2024 15:18:24
Baseurl du dépôt : http://mirror.in2p3.fr/pub/linux/centos-stream/9-stream/CRB/x86_64/os/ (94 more)
Expirat° du dépôt : 21600 secondes (dernier : lun. 21 oct. 2024 15:18:24)
Nom de fichier du dépôt : /etc/yum.repos.d/centos.repo
And the regex always fails because there's no Repo-id
in the output.
Issue Type
Bug Report
Component Name
dnf_config_manager
Ansible Version
$ ansible --version
ansible [core 2.17.5]
config file = /etc/ansible/ansible.cfg
configured module search path = ['/home/victor.bouvierdeleau/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
ansible collection location = /home/victor.bouvierdeleau/.ansible/collections:/usr/share/ansible/collections
executable location = /usr/bin/ansible
python version = 3.10.12 (main, Sep 11 2024, 15:47:36) [GCC 11.4.0] (/usr/bin/python3)
jinja version = 3.0.3
libyaml = True
Community.general Version
$ ansible-galaxy collection list community.general
# /usr/lib/python3/dist-packages/ansible_collections
Collection Version
----------------- -------
community.general 9.5.0
Configuration
$ ansible-config dump --only-changed
CONFIG_FILE() = /etc/ansible/ansible.cfg
EDITOR(env: EDITOR) = vim
PAGER(env: PAGER) = less
OS / Environment
Ansible Controller OS : Ubuntu 22.04.5 LTS running in WSL on Windows 11, ansible
installed from the official PPA
Target OS : CentOS Stream 9
Steps to Reproduce
For the target machine :
- Get a CentOS Stream 9 machine running
- Create a user and set its locale to
fr_FR.UTF-8
- Add the user to the
wheel
group
Example playbook :
---
- name: 'Debug'
hosts: 'host'
become: true
tasks:
- name: 'Enable CRB repository'
community.general.dnf_config_manager:
name: 'crb'
state: 'enabled'
Expected Results
The dnf_config_manager
module should enable the CRB repository.
Actual Results
TASK [role : Enable CRB repository] *************************************************************************************************************************************************************
fatal: [host]: FAILED! => {"changed": false, "msg": "did not find repo with ID 'crb' in dnf repolist --all --verbose"}
Workaround
I've simply changed the task to force the locale to en_US.UTF-8
like so:
---
- name: 'Debug'
hosts: 'host'
become: true
tasks:
- name: 'Enable CRB repository'
community.general.dnf_config_manager:
name: 'crb'
state: 'enabled'
environment:
LANG: 'en_US.UTF-8'
Code of Conduct
- [X] I agree to follow the Ansible Code of Conduct