Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1863039

Summary: dnf uploadprofile does not read variables set by files in /etc/yum/vars/
Product: Red Hat Enterprise Linux 8 Reporter: jcastran
Component: subscription-managerAssignee: Jiri Hnidek <jhnidek>
Status: CLOSED ERRATA QA Contact: Red Hat subscription-manager QE Team <rhsm-qe>
Severity: medium Docs Contact:
Priority: medium    
Version: 8.2CC: candlepin-bugs, dbodnarc, dvolkov, f.van.ginkel, james.antill, jhnidek, jsefler, ktordeur, mblaha, qianzhan, redakkan, shughes, wpoteat
Target Milestone: rcKeywords: Triaged, ZStream
Target Release: 8.5Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: subscription-manager-1.28.16-1.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1951053 (view as bug list) Environment:
Last Closed: 2021-11-09 19:37:33 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1951053    

Comment 1 Jaroslav Mracek 2020-08-10 12:57:52 UTC
Due to the issue is reported only for the `dnf uploadprofile` command provided by subscription manager and not by any other dnf provided commands I suggest that the issue is related to subscription manager (changing the component). Please don't hesitate to contact me when you will need an assistance with resolving the issue.

Comment 2 William Poteat 2020-08-26 15:17:39 UTC
The substitutions are made from /etc/yum/vars by yum/dnf for actions that are coded as part of yum/dnf
This action is wholly created and maintained in subscription manager and that is not been accounted for. We need to expand that functionality to also incorporate any variables where indicated and available in /etc/yum/vars.

Comment 3 Marek Blaha 2020-09-17 14:39:37 UTC
I checked the dnf variable substitutions code and find out, that variables from /etc/yum/vars are not loaded automatically. There is an API call for loading them - `conf.substitutions.update_from_etc(installroot, varsdir=("/etc/yum/vars/", "/etc/dnf/vars/"))` and subscription manager plugin is not calling it. Unfortunately this API is not documented in DNF documentation so please check the source code instead: https://github.com/rpm-software-management/dnf/blob/241c258489ca152f19a27aa0309b7e8d0166812c/dnf/conf/substitutions.py#L44 .

With this small change in subscription manager the variables are read from config files and the plugin seems to start working:

diff --git a/src/rhsm/profile.py b/src/rhsm/profile.py
index d5ccee6d1..d57beefa7 100644
--- a/src/rhsm/profile.py
+++ b/src/rhsm/profile.py
@@ -83,6 +83,7 @@ class ModulesProfile(object):
         module_list = []
         if dnf is not None and libdnf is not None:
             base = dnf.Base()
+            base.conf.substitutions.update_from_etc("/")
             base.read_all_repos()
             try:
                 base.fill_sack()

I'm not sure about using "/" as an install root - I did not check if the install root could possibly be other.

Comment 10 Rehana 2021-04-27 09:07:52 UTC
*** Bug 1765053 has been marked as a duplicate of this bug. ***

Comment 11 Shwetha Kallesh 2021-04-29 06:42:42 UTC
Reproducer:

[root@kvm-03-guest18 ~]# subscription-manager version
server type: Red Hat Subscription Management
subscription management server: 3.2.16-1
subscription management rules: 5.41
subscription-manager: 1.27.16-1.el8


[root@kvm-03-guest18 ~]# echo "mirrors.fedoraproject.org" > /etc/yum/vars/contenthost

[root@kvm-03-guest18 ~]# dnf uploadprofile
Updating Subscription Management repositories.
Errors during downloading metadata for repository 'epel':
  - Curl error (6): Couldn't resolve host name for https://$contenthost/metalink?repo=epel-8&arch=x86_64&infra=$infra&content=$contentdir [Could not resolve host: $contenthost]

Comment 12 Shwetha Kallesh 2021-04-29 06:52:20 UTC
Pre-verification comments:

'dnf uploadprofile' now reads variables set by files in /etc/yum/vars/

[root@kvm-07-guest10 ~]# subscription-manager version
server type: Red Hat Subscription Management
subscription management server: 3.2.16-1
subscription management rules: 5.41
subscription-manager: 1.28.16-1.el8


[root@kvm-07-guest10 ~]# echo "server.hostname" > /etc/yum/vars/contenthost
[root@kvm-07-guest10 ~]# dnf uploadprofile 
Updating Subscription Management repositories.
Errors during downloading metadata for repository 'epel':
  - Curl error (6): Couldn't resolve host name for https://server.hostname/metalink?repo=epel-8&arch=x86_64&infra=$infra&content=$contentdir [Could not resolve host: server.hostname]
^^ observe that value of the variable contenthost is read , server.hostname is value of the variable contenthost

Package profile updates
        status: 1
        updates: []
        exceptions: 
        
[root@kvm-07-guest10 ~]# echo "mirrors.fedoraproject.org" > /etc/yum/vars/contenthost
[root@kvm-07-guest10 ~]# dnf uploadprofile 
Updating Subscription Management repositories.
Last metadata expiration check: 0:01:13 ago on Thu 29 Apr 2021 02:32:32 AM EDT.
Package profile updates
        status: 1
        updates: []
        exceptions:

Comment 16 Shwetha Kallesh 2021-05-17 06:34:25 UTC
Verification:


[root@kvm-03-guest08 ~]# subscription-manager version
server type: Red Hat Subscription Management
subscription management server: 3.2.18-1
subscription management rules: 5.41
subscription-manager: 1.28.16-1.el8

[root@kvm-03-guest08 ~]# cat /etc/yum.repos.d/local.repo 
[local_repo]
baseurl=http://$contenthost/shwetha_repo/
gpgcheck=0


[root@kvm-03-guest08 ~]# echo "server.hostname" > /etc/yum/vars/contenthost
[root@kvm-03-guest08 ~]# dnf uploadprofile 
Updating Subscription Management repositories.
Errors during downloading metadata for repository 'local_repo':
  - Curl error (6): Couldn't resolve host name for http://server.hostname/shwetha_repo/repodata/repomd.xml [Could not resolve host: server.hostname]
                                                           ^^ observe the value of the variable 'contenthost' which is "server.hostname" is used
Package profile updates
        status: 1
        updates: []
        exceptions: 
        
[root@kvm-03-guest08 ~]# echo "shwetha-workstation.usersys.redhat.com" > /etc/yum/vars/contenthost

[root@kvm-03-guest08 ~]# dnf uploadprofile 
Updating Subscription Management repositories.
Package profile updates
        status: 1
        updates: []
        exceptions: 

^^ observe $contenthost is replaced by the hostname "shwetha-workstation.usersys.redhat.com"

Comment 19 errata-xmlrpc 2021-11-09 19:37:33 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (subscription-manager bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2021:4390