class foo(
$owner,
$prefix = "/opt/${owner}",
$etc_dir = "${prefix}/etc"
) {
file{"${etc_dir}":
ensure => directory,
owner => $owner,
group => $owner,
mode => 0660,
...
}You need to move the logic computing the resulting defaults inside the
class to be able to use the $owner and $prefix values.
Regards
- henrik
> --
> You received this message because you are subscribed to the Google
> Groups "Puppet Users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/puppet-users/-/AjNp3Hlh8woJ.
> To post to this group, send email to puppet...@googlegroups.com.
> To unsubscribe from this group, send email to
> puppet-users...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/puppet-users?hl=en.
Yes. The issue with parameters in class declaration is described in
further details here:
http://projects.puppetlabs.com/issues/9848
> Also, what if I want to be able to override these with user settings?
> (That's one of the reasons that they are parameters in the first place.)
John's example works with the edge case where you actually want to set
a variable to '', you'll see our documentation list 'UNSET' as the
default for this reason:
http://docs.puppetlabs.com/guides/parameterized_classes.html
Thanks,
Nan