Hi Eirik,

the parameter behavior is actually the other way around:

class foo:bar(
$param1,         # This enables you to provide 'param1' when instantiating 
the class,
                 # and it enables auto-parameter-lookup for 
foo::bar::param1 in Hiera.
                 # if no value is given or found in Hiera, the value of 
$param1 will be undef.

$param2='test'   # This enables you to provide 'param2' when instantiating 
the class,
                 # and it enables auto-parameter-lookup for 
foo::bar::param2 in Hiera.
                 # if no value is given or found in Hiera, the value of 
$param2 will be 'test'.
) { ... }

In other words, specifying =<some value> after a parameter in the class 
parameter definition, will enable you to provide a default value that is 
used as a last resort.

-Kevin

On Thursday, October 18, 2018 at 10:50:15 AM UTC+2, Eirik Øverby wrote:
>
> Hi, 
>
> > I don't fully understand Part 2: "2. You need any applicable 
> resource-like declaration of class postgresql::server in the manifest set 
> to not itself bind a value to the config_hash parameter." 
>
> You are probably declaring your class/resource setting default values for 
> parameters directly in the .pp file. This will override whatever you're 
> defining in Hiera. Just leave the declaration like 
>
> class foo:bar ( $param1, $param2='test' ) { ... } 
>
> In this way $param1 is considered mandatory, and if it's defined in hiera 
> all is good (the hiera value will be used). Rparam2 is optional, and will 
> be assigned the value 'test' no matter what hiera says - unless you 
> instantiate the class with that parameter explicitly set. 
>
> /Eirik

-- 
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/c2931a67-fe86-4fdc-99e2-b4e11d4d97e2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to