When I use a definition instead of a class in a puppet, what's the best practice for parameters?

I understand that it’s generally a good idea to create params.pp in a module with the class modulename :: params and inherit that in the modulename class to process the parameters in a separate file. How to do this if I create a definition instead of a class?

To clarify, I use the definition to be able to install multiple versions of the same application on the server.

+3
source share
1 answer
Good question. Since there is no inheritance for dolls for certain types, params.pp templates cannot be reproduced in the same way for certain types as for classes. However, there is another way.

"hello world" Foo ['bar'] :

class params {
  $msg = 'hello world'
}
define foo($msg = $params::msg ) {
  notify{ $msg: }
}

foo { 'bar': }
include params

, , params. Puppet , , $params::msg .

, Puppet . , , :

foo { 'bar':
  require => Class['params'] # <- not necessary
}
include params

, , foo, params, , init.pp :

include foo::params
define foo($x = $foo::params::x, $y = $foo::params::y, ...) 

params.pp, : params.pp

+5

All Articles