2

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?

Luke404
  • 5,826
  • 4
  • 47
  • 58
  • 2
    Not sure about on Gentoo, but on Debian `lsbdistid` doesn't exist unless the `lsb-release` package is installed. So a bare minimum install will not have `lsbdistid`. – Zoredache Feb 14 '13 at 17:43
  • Which fact to choose depends entirely on the differences between systems you're trying to account for. You didn't give this information. – Michael Hampton Feb 14 '13 at 20:03
  • the idea is to write modules that can be reusable accross different systems - that's why I discarded osfamily, it doesn't differentiate at least one system (Gentoo) from the others. I don't know if there are other similar differences between lsbdistid and operatingsystem, or if they are equal. Zoredache's comment suggests the latter is not true. – Luke404 Feb 14 '13 at 20:56
  • I would guess the reason for that is that almost nobody using puppet also uses Gentoo, so it's not well supported. You might consider adding some support and contributing it back to the project. – Michael Hampton Feb 14 '13 at 22:17

2 Answers2

5

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
  }
}
Anton Cohen
  • 1,142
  • 7
  • 8
  • Thank you. Re facter on Gentoo, I'm happily running it in production (with puppet) since early 2011 - it's just osfamily that is too generic even on the latest facter-1.6.16 – Luke404 Feb 15 '13 at 00:04
0

That's a bit tricky, because at the end of the day every OS acts a bit differently. First of all decide, which distros your module wants to support and then test it.

Also I don't see any reasons why not to use both facts as a way to distinguish the distribution. There is nothing wrong with that.

golja
  • 1,621
  • 10
  • 14