I am setting up a yum repository, and need to debug some of the URLs in the yum.conf file. I need to know why is Scientific Linux trying to grab this URL, when I was expecting it to grab another URL:
# yum install package
http://192.168.1.100/pub/scientific/6.1/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404"
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: sl. Please verify its path and try again
The yum.conf(5) manpage gives some information about these variables:
Variables
There are a number of variables you can use to ease maintenance of
yum's configuration files. They are available in the values of several
options including name, baseurl and commands.$releasever This will be replaced with the value of the version of the
package listed in distroverpkg. This defaults to the version of
'redhat-release' package.$arch This will be replaced with your
architecture as listed by os.uname()[4] in Python.$basearch This will be replaced with your base architecture in yum.
For example, if your $arch is i686 your $basearch will be i386.$YUM0-$YUM9 These will be replaced with the value of the shell
environment variable of the same name. If the shell environment
variable does not exist then the configuration file variable will not
be replaced.
Is there a way to view these variables by using the yum
commandline utility? I would prefer to not hunt down the version of the 'redhat-release' package, or manually get the value of os.uname()[4] in Python.
Best Answer
When this answer was written in 2011, json wasn't installed for python by default for all the versions of RHEL/CentOS at that time so I used pprint to print the stuff nicely.
It is now 2020 and all current versions of RHEL/CentOS have json by default for python. The answer has been updated to use json and updated to include RHEL/CentOS 8 by modifying @sysadmiral's answer for Fedora.
RHEL/CentOS 8:
RHEL/CentOS 6 and 7
RHEL/CentOS 4 and 5
Example output:
Original answer below:
If you install
yum-utils
, that will give youyum-debug-dump
which will write those variables and more debugging info to a file. There is no option to write to stdout, it will always write to some file which really isn't that helpful.This is obviously not a great solution so here's a python one-liner you can copy and paste which will print those variables to stdout.
python -c 'import yum, pprint; yb = yum.YumBase(); pprint.pprint(yb.conf.yumvar, width=1)'
This works on CentOS 5 and 6, but not 4. yum is written in python, so the yum python module is already on your server, no need to install anything exra.
Here's what it looks like on CentOS 5: