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-manager | Assignee: | Jiri Hnidek <jhnidek> | |
| Status: | CLOSED ERRATA | QA Contact: | Red Hat subscription-manager QE Team <rhsm-qe> | |
| Severity: | medium | Docs Contact: | ||
| Priority: | medium | |||
| Version: | 8.2 | CC: | candlepin-bugs, dbodnarc, dvolkov, f.van.ginkel, james.antill, jhnidek, jsefler, ktordeur, mblaha, qianzhan, redakkan, shughes, wpoteat | |
| Target Milestone: | rc | Keywords: | Triaged, ZStream | |
| Target Release: | 8.5 | Flags: | 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
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. 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.
*** Bug 1765053 has been marked as a duplicate of this bug. *** 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] 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: 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" 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 |