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

dnf_config_manager: doesn't work when the locale of the remote_user is not english #9046

Closed
1 task done
PlqnK opened this issue Oct 21, 2024 · 2 comments · Fixed by #9157
Closed
1 task done

dnf_config_manager: doesn't work when the locale of the remote_user is not english #9046

PlqnK opened this issue Oct 21, 2024 · 2 comments · Fixed by #9157
Labels
bug This issue/PR relates to a bug module module plugins plugin (any type)

Comments

@PlqnK
Copy link

PlqnK commented Oct 21, 2024

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 :

REPO_ID_RE = re.compile(r'^Repo-id\s*:\s*(\S+)$')

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 :

  1. Get a CentOS Stream 9 machine running
  2. Create a user and set its locale to fr_FR.UTF-8
  3. 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

  • I agree to follow the Ansible Code of Conduct
@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

@ansibullbot
Copy link
Collaborator

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

Successfully merging a pull request may close this issue.

2 participants