You need to do like this:
class myClass (
String $base_dir,
Optional[String] $conf_dir,
) {
if $myClass::conf_dir == undef {
$myClass::actual_conf_dir = "$myClass::base_dir/conf”
} else {
$myClass::actual_conf_dir = $myClass::conf_dir
}
… and then use $myClass::actual_conf_dir in the template
}
> On Oct 3, 2018, at 12:41 PM, Jody Des Roches <[email protected]> wrote:
>
> I'd like to set default values for parameters that will be passed to epp
> templates. However, the default value is based on another parameter. I
> understand that variables are immutable but this is a parameter that
> shouldn't be touched unless it wasn't set.
>
> Here is an example construct with a few of my syntax attempts.
>
> class myClass (
> String $base_dir,
> Optional[String] $conf_dir,
> ) {
> #Attempt 1: Failed
> if $myClass::conf_dir == undef { $myClass::conf_dir =
> "$myClass::base_dir/conf" }
>
> #Attempt 2: Failed
> if !$myClass::conf_dir { $myClass::conf_dir = "$myClass::base_dir/conf" }
>
> #Attempt 3: Failed
> unless $myClass::conf_dir { $myClass::conf_dir = "$myClass::base_dir/conf" }
> }
>
> --
> 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/8e2db8c1-7353-4360-adc5-00713e1c0214%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
--
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/15795E9D-F2CE-4AE1-91B8-9BD3E78CDD3A%40icloud.com.
For more options, visit https://groups.google.com/d/optout.