Fix yum error showing wrong $releasever

I just recently changed my yum configuration to use CentOS repositories, instead of the Redhat repositories on RHN that require a license. Little did I know, this also changed my OS to CentOS after updating all of my packages and base system. It did not, however, update my yum configuration so that the next time I ran yum, I got something like this:

not using ftp, http[s], or file for repos, skipping - 5Server is not a valid release or hasnt been released yet
Error: Cannot find a valid baseurl for repo: base

5Server is the output of “$releasever” in the python script that is /usr/bin/yum. You can go down that bunny trail yourself, or save that time and read the next few lines.

I thought it was generated by parsing /etc/redhat-release, but it is really reading it from a package. I didn’t bother to go as far as why or how, but I simply had to remove the offending package:

yum erase redhat-release-5Server-5.5.0.2

I found that package by running

rpm -qa | grep -i release

and now it all works again.