To clarify, I am looking on how to store a yum variable as the RESULT of a command. The command I use to get the OS version is irrelevant to me, I'm sure there are better ways of getting it than what I've done below.
I want to create a custom yum variable that is the result of running
cat /etc/redhat-release | awk '{ print $3 }'
The documentation for creating variables seems to only allow for creating static variables inside a file in /etc/yum/vars/$variablename
.
So what I want is to have /etc/yum/vars/dotrelease
be the output of my command above, based on the system I am on.
Then I can set my baseurl repo to http://localrepo.com/repo/centos/$dotrelease/os/$basearch/
My custom repo is separated by dot release, where by default $releasever only looks the numbered release, for example, the $releasever variable on centos6.4 is "6".
I realize I can just
echo (cat /etc/redhat-release | awk '{ print $3 }') > /etc/yum/vars/dotrelease
but I'd have to run that on every machine I deploy, instead of just keeping the variable in a file.