[NBLUG/talk] Troubleshooting yum

Lincoln Peters anfrind at gmail.com
Fri Feb 22 09:40:56 PST 2013


I'm working on a tool that needs to be able to detect if a host running
RHEL 5 or 6 has a bad yum repository (host is unreachable, directory does
not exist, etc.) and report exactly which repository or repositories are
bad. Originally (and before I discovered that yum has a Python API), I
would do the following:

1. Run a Python script that parses all of the files under /etc/yum.repos.d
and prints out the names of all enabled repositories.
2. For each reported host, run: yum --disablerepo='*' --enablerepo=<repo>
repolist
3. If any of those commands return a non-zero exit code, report them as bad.

This worked perfectly on RHEL 5 as recently as 5.7 (running yum 3.2.22),
although I haven't tested on RHEL 5.8.  However, it looks like something
changed in the version of yum that ship with later RHEL versions. In RHEL
6.2 (yum 3.2.29), "yum repolist" now appears to skip bad repositories, so I
can't tell by the exit code if the repository is bad ("yum check-update
still returns the expected exit code).  And on RHEL 6.3 (a newer build of
yum 3.2.29), I have one machine that doesn't seem to consider bad
repositories worthy of reporting via exit code at all (even "yum
check-update" returns 0 if a repository is bad), and I have another machine
(running CentOS, but still yum 3.2.29) that returned with exit code 1 if a
repository is bad, just as I would expect.

Anyone know what's behind this change in behavior?  The yum changelog
offers no clues.

Bonus question: for my purposes, would it be easier to write a Python
script that uses yum's sparsely-documented API than to execute it from the
command line and rely on exit codes?  (I do know Python pretty well, but
the documentation for the yum API is pretty rudimentary.)

Thanks in advance.

-- 
Lincoln Peters
<anfrind at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nblug.org/pipermail/talk/attachments/20130222/46a63814/attachment.html>


More information about the talk mailing list