Jul11

puppet fact for CentOS Version

Posted by Karanbir Singh on 11/Jul/2008  ~  Posted in: Linux, Software

I looked and found nothing for this, so wrote this quick fact for puppet.

# centos_version.rb

Facter.add("centos_version") do
  setcode do
    %x{/bin/rpm --qf "%{version}\n" -q centos-release}.chomp
  end
end

Once its in your facts/ you can do things like this in your puppet manifests :

case $centos_version {
4: { ... }
5: { ... }
default: { .... }
}

- KB