Hi,
//I use params_lookup (lib from puppi)
https://github.com/example42/puppi/blob/master/lib/puppet/parser/functions/params_lookup.rb
it lookup in this order (first match is returned)
- Hiera backend (if present) for modulename_varname
- Hiera backend (if present) for varname (if second argument is 'global')
- Top Scope Variable ::modulename_varname
- Top Scope Variable ::varname (if second argument is 'global')
- Module default: ::modulename::params::varname
So all my classes are based on this tpl :
class my_class::params {
$config_param = 'default value'
}
class my_class (
$config_param = params_lookup('config_param'),
$global_param = params_lookup('global_param','global')
) inherits my_class::params {
...
}
Best regards,
Le 30/08/2014 18:23, Sirtaj Singh Kang a écrit :
Greetings all,
In the pre-hiera days, it was commonly recommended to write classes
with params like this:
class my_class::params {
$config_param = 'default value'
}
class my_class (
$config_param = $myclass:params::config_param
) inherits myclass::params {
...
}
However, now that much overriding, customising etc has moved into
Hiera, this ends up being very verbose, redundant and error-prone,
especially if there are a lot of parameters (to go into a config
template, for example). The same parameter name may end up in four
different places in common cases: hiera, params, class decl and the
config template.
So I would like to know if people are still doing this as much as
possible. What is the remaining benefit in declaring defaults in
params rather than in the class declaration directly? Is there a more
up to date style guide that does away with the verbosity and
duplication, or is the old params class style still widely recommended?
Thanks for any suggestions,
-Taj.
--
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 puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/54021880.3090505%40quake.fr.
For more options, visit https://groups.google.com/d/optout.