Writing modules: detecting package manager and init system
Say, I want to write a module which installs a package, and runs a service. I want to include most OS-es (well, Linuxes at least). For this, I need to know:
- the package manager in use (am I going to add a yum or an apt repo?)
- the init system in use (am I going to add config for SysV, upstart, systemd?)
... now, Puppets documentation for packages and for services just claim 'Puppet will usually find this out on its own', however, as I need to code adding that repo, or figure out which init config file to put where, does it actually expose this kind of information anywhere? Looking through facts & code, I don't see it anywhere, and looking at some mature modules they all seem to re-invent the wheel in checking operating systems & going for what should be default there. So, in short, my question is:
- Does Puppet itself expose this kind of information anywhere in a module?
- And if not, is there a module specifically to do this, which I can use?
... because basically, having just an
if $::packagemanager == 'yum' or
if $::initsystem == 'upstart' does seem a whole lot cleaner than an entire tree of
$::osfamily stuff, with all the possible version comparisons as well.