redhat-cop/infra.osbuild

RHSM Repos Not Handled Correctly

jjaswanson4 opened this issue · 4 comments

When running with additional RHSM repos, the collection does not appropriately handle enabling them:

TASK [infra.osbuild.builder : Get rhsm repos properties] *************************************************************************************************************************************************************************************************************************************************************************************
fatal: [edge-manager-local]: FAILED! => {"changed": false, "msg": "Could not find {'name': 'rhel-9-for-x86_64-rt-rpms'} in the files inside /etc/yum.repos.d/ directory. Error: <class 'Exception'>"}

Tested on:

(.venv) [jswanson@jswanson-fedora device-edge-workshops]$ ansible --version
ansible [core 2.14.1]
  config file = /home/jswanson/code/device-edge-workshops/ansible.cfg
  configured module search path = ['/home/jswanson/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/jswanson/code/device-edge-workshops/.venv/lib64/python3.10/site-packages/ansible
  ansible collection location = /home/jswanson/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/jswanson/code/device-edge-workshops/.venv/bin/ansible
  python version = 3.10.11 (main, Apr  5 2023, 00:00:00) [GCC 12.2.1 20221121 (Red Hat 12.2.1-4)] (/home/jswanson/code/device-edge-workshops/.venv/bin/python3)
  jinja version = 3.1.2
  libyaml = True

Target is EL9.2, and the system can enable the repo via SM:

sudo subscription-manager repos --enable=rhel-9-for-x86_64-rt-rpms
Repository 'rhel-9-for-x86_64-rt-rpms' is enabled for this system.

variables:

    builder_compose_type: edge-commit
    builder_blueprint_name: rhde-rt-image
    builder_compose_pkgs:
      - vim-enhanced
      - git
      - nano
      - NetworkManager-wifi
      - podman
    builder_rhsm_repos:
      - name: rhel-9-for-x86_64-rt-rpms
    builder_compose_customizations:
      user:
        name: ansible
        password: "{{ admin_password }}"
        groups:
          - wheel
      kernel:
        name: kernel-rt

I believe the issue is here: https://github.com/redhat-cop/infra.osbuild/blob/main/plugins/modules/rhsm_repo_info.py#L62-L64

I assume the idea here is to match all *.repo files in /etc/yum.repos.d and then parse them. I'm not sure why /etc/yum.repos.d/redhat.repo isn't being matched/parsed, but it does exist on the system:

ls -lsa /etc/yum.repos.d/*.repo
100 -rw-r--r--. 1 root root 98498 Jun  5 13:01 /etc/yum.repos.d/redhat.repo

That file does contain the appropriate repo info:

grep 'rhel-9-for-x86_64-rt-rpms' /etc/yum.repos.d/redhat.repo -A 12
[rhel-9-for-x86_64-rt-rpms]
name = Red Hat Enterprise Linux 9 for x86_64 - Real Time (RPMs)
baseurl = https://cdn.redhat.com/content/dist/rhel9/$releasever/x86_64/rt/os
enabled = 0
gpgcheck = 1
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
sslverify = 1
sslcacert = /etc/rhsm/ca/redhat-uep.pem
sslclientkey = /etc/pki/entitlement/6206708589931907112-key.pem
sslclientcert = /etc/pki/entitlement/6206708589931907112.pem
sslverifystatus = 1
metadata_expire = 86400
enabled_metadata = 0

@jjaswanson4 I was able to reproduce this issue. I will start working on a fix.

@jjaswanson4 I found the issue, the list of rhem repos shouldn't have name:
This will work:

    builder_compose_type: edge-commit
    builder_blueprint_name: rhde-rt-image
    builder_compose_pkgs:
      - vim-enhanced
      - git
      - nano
      - NetworkManager-wifi
      - podman
    builder_rhsm_repos:
      - rhel-9-for-x86_64-rt-rpms
    builder_compose_customizations:
      user:
        name: ansible
        password: "{{ admin_password }}"
        groups:
          - wheel
      kernel:
        name: kernel-rt

I'm closing this issue