Bug 1955723 - DNF not picking up amazon-id dnf module when in a virtual env
Summary: DNF not picking up amazon-id dnf module when in a virtual env
Status: NEW
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: dnf
Version: 8.3
Hardware: Unspecified
OS: Unspecified
Target Milestone: beta
: ---
Assignee: Packaging Maintenance Team
QA Contact: swm-qe
Depends On:
TreeView+ depends on / blocked
Reported: 2021-04-30 17:33 UTC by David Luong
Modified: 2021-05-04 14:10 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Last Closed:
Type: Bug
Target Upstream Version:

Attachments (Terms of Use)

Description David Luong 2021-04-30 17:33:50 UTC
Description of problem:
When utilizing dnf through ansible module in a virtualenv, it fails to pick up amazon-id.py in dnf-modules

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. sudo python3 -m venv /usr/local/python-ansible --system-site-packages
2. sudo /usr/local/python-ansible/bin/pip3 install -U pip
3. sudo /usr/local/python-ansible/bin/pip3 ansible==2.9.20 boto3

Actual results:
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Failed to download metadata for repo 'rhui-client-config-server-8': Cannot prepare internal mirrorlist: Curl error (6): Couldn't resolve host name for https://rhui3.REGION.aws.ce.redhat.com/pulp/mirror/protected/rhui-client-config/rhel/server/8/x86_64/os [Could not resolve host: rhui3.REGION.aws.ce.redhat.com]", "rc": 1, "results": []}

Expected results:
    "results": [
        "Installed: telnet-1:0.17-74.el8_3.1.x86_64"

Additional info:
We can see that it's not picking it up since REGION isn't getting substituted like it's supposed to in amazon-id.py:

    def _fix_rhui_url_template(self, repo, region):
        if region in REDIRECT_MAP:
            region = REDIRECT_MAP[region]

        if repo.baseurl:
            repo.baseurl = tuple(
                url.replace('REGION', region, 1) for url in repo.baseurl
        elif repo.mirrorlist:
            repo.mirrorlist = repo.mirrorlist.replace('REGION', region, 1)
            raise dnf.exceptions.RepoError("RHUI repository %s does not have an url" % repo.name)

The workaround for this is setting pluginpath in dnf.conf:

Comment 1 David Luong 2021-04-30 17:43:04 UTC
The 4th step to reproduce is to run ansible-playbook from within the venv, where example.yaml contains a task that installs a package with dnf module:

/usr/local/python-ansible/bin/ansible-playbook example.yaml

- hosts: localhost
  - name: Install telnet
      state: present
      name: telnet

Note You need to log in before you can comment on or make changes to this bug.