Puppet: Need major version fact

I've often needed to seperate settings pr. a distros major relase in puppet.

f.ex. CentOs-6 is different than CentOs-5 -  but there's no difference between v5.6 and 5.7.

Unfortunately there's no fact in puppet that gives this. I've had an $osversion fact - which simply concat'ed $operatingsystem and $lsbmajdistrelease - but that last fact depends on lsbdistrelease - which depends on lsb_release, which on Red Hat 6 is delivered by redhat-lsb package - which pulls in ~90 packages!

I found it absolutely absurd to have to install ~90 packages, just to get such a simple fact, and since we always have $operatingsystemrelease - I modified my osversion.rb fact to this:

Facter.add("osversion") do
    setcode do
        maj = Facter.value('operatingsystemrelease').split('.')
        distid = Facter.value('operatingsystem') + "-" + maj.first

Now I have $osversion which contains RedHat-6, CentOs-5 or whatever. IMHO I need to fix it, to ensure the "major logic" is kept - so f.ex. Ubuntu-12.04 would be the content of $osversion - instead of Ubuntu-12 - as that's the actual major version - one cannot expect everything to work the same in 12.10 (this also goes for other distros with date-based releasenumbers :)

0 comments on Puppet: Need major version fact