Le 26/10/2013 16:18, Jason Antman a écrit :
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
I agree with you as long as a different OS does not require something really different than the other ones. As long as you only need to change package/service names, or few file path, that's easy.

Let's say that a tool on OS 'A' needs 10 packages and 1 service to be operational and on OS 'B', it just needs 5 config files (for some totally unknown reason, just an example). In this case, configuring this service with a list of variable in params.pp won't do the trick.

You will need a couple of 'if' in your main classes. That means that one day, when you will drop OS 'B' support, you will have to modify all your classes and this will be the uneasy path I would like to avoid.



Aurélien

--
You received this message because you are subscribed to the Google Groups "Puppet 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/52713EFD.9090101%40cea.fr.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to