Puppet & Facter - how to determine if running Cent 6 or Cent 5
There is operatingsystemmajrelease
% facter operatingsystemmajrelease
6
If you have redhat-lsb-core package installed, facter will get as well the family of lsb-provided facts (which includes lsbmajdistrelease):
% facter |grep ^lsb
lsbdistcodename => Final
lsbdistdescription => CentOS release 6.4 (Final)
lsbdistid => CentOS
lsbdistrelease => 6.4
lsbmajdistrelease => 6
lsbrelease => :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch
NOTE: You need at least Facter 1.7 in order have operatingsystemmajrelease
. Core facts in Facter 1.6 are quite limited.
I'm guessing that you are trying to make some sort of decision based off of the install version.
You can use regexes in your logic.
So something like:
case $operatingsystemrelease {
/^6.*/: {
//do 6.x stuff
}
/^5.*/: {
//do 5.x stuff
}
}
or if if
is more your style:
if $operatingsystemrelease =~ /^6.*/ {
//do 6.x stuff
}
elsif $operatingsystemrelease =~ /^5.*/ {
// do 5.x stuff
}
Remember that all factor facts are available in global scope variables to your manifests.
If you have a mixed environment you will probably want to wrap that in in something like:
if $operatingsystem == "CentOS" {
}