Re: [Puppet Users] Best practice to manage multi-OS for the same module?

Jason Antman
2013-10-26T14:18:33Z

Aurélien,

I''m a fan of the params.pp pattern, as is used in a lot of
puppetlabs''
own modules. Most of the current modules use parameterized classes, so
if you''re using a less-capable ENC (like the current Puppet Dashboard /
Console, ironically) you''ll need to write wrapper classes.

To see what I''m referring to, look at the puppetlabs-puppet module,
specifically:
https://github.com/puppetlabs/puppetlabs-puppet/blob/master/manifests/init.pp
and
https://github.com/puppetlabs/puppetlabs-puppet/blob/master/manifests/params.pp

The classes that are directly used (like ''puppet'' itself, in
init.pp)
are parameterized, inherit puppet::params, and use
$puppet::params::VariableName as defaults which can be overridden.
Inside of puppet::params, there is a case statement that sets variables
based on operatingsystem (or other facts, or combinations).

You can certainly do this without *needing* the parameterized classes,
just by requiring a params subclass, and setting your os-specific
defaults there. I really like this pattern because:
- it keeps big multi-branch conditionals in one place, instead of
scattered around your code
- it provides one place to look to confirm which OSes the module supports
- it provides one place to go to extend the module for new OSes

-Jason Antman

On 10/24/2013 06:13 AM, DEGREMONT Aurelien wrote:
> Hello all,
>
> As said in the subject, I did not find in puppet doc the official
> recommendation in how multi-os should be handled in module manifests.
>
> Let''s say I want my module foo having classes that could be used
on
> Debian, RHEL6 and Fedora 10 to 18.
> What would be the recommended way to manage differences between all of
> these systems?
>
> I know there is conditionals usable in classes, but is this the
> recommended way?
>
> Also, when I decommission" Fedora10" by example, and I do not
want to
> manage it in all my modules anymore, as this is unneeded complexity, I
> need to modify all the "if" statement in all modules to remove
> fedora10 special treatments?
>
>
> Aurélien