Puppet facts: should we use lsbdistid or operatingsystem

facterpuppet

With current versions of Puppet and Facter I get the same information in the lsbdistid and operatingsystem facts – I don't look at osfamily because on Gentoo Linux it reports a generic "Linux" string.

When using that piece of information in Puppet modules (eg. for choosing package names to be installed) is there any technical reason or established consensus to use lsbdistid or operatingsystem?

Best Answer

I like osfamily. LSB is often not installed by default and on some distros like RHEL/CentOS the dependency chain for lsb_release is huge. Plus, if you don't know the distro how do you know the name of the LSB package? operatingsystem is annoying because I usually don't care whether it is RedHat vs. CentOS, or Debian vs. Ubuntu. I want to know distro families because the idiosyncrasies between distros are usually the same within families.

Gentoo support was merged into facter's osfamily yesterday (Feb 13, 2013), it should make the next release. You can always use a combination of osfamily to check Debian or RedHat and operatingsystem to check for Gentoo.

osfamily and operatingsystem are basically just a bunch of if or case conditions. It would be pretty easy to customize your own as a custom fact or class parameter based on your needs. Like:

class osfacts {
  if $::kernel == 'Linux' {
    $os = $::operatingsystem ? {
      Gentoo => 'Gentoo',
      default => $::osfamily,
    }
  }
  elsif $::kernel == 'SunOS' {
    $os = $::operatingsystem
  }
  elsif ($::operatingsystem == 'Darwin') and
        ($::macosx_productname == 'Mac OS X') {
    $os = 'MacOSX'
  }
  else {
    $os = $::operatingsystem
  }
}