Take this wrapper around ssh_authorized_key for example:
define sshauthkeys::helper ($user,$ensure='present') {
ssh_authorized_key { "puppet: ${name2} ${user}":
ensure => $ensure,
type => $ssh_keys["${name2}"]["type"],
key => $ssh_keys["${name2}"]["key"],
user => "${user}"
}
}
Let's say I wanted to introduce support of the 'target' parameter for that resource type, I'd do something like:
define sshauthkeys::helper ($user,$ensure='present', $target='') {
The problem is, if I want to use the sensible default from puppet derived from $user 's homedir - and override it on fringe cases, I lose the benefit of the work done to set the default in all of the other circumstances.
Is there a way to optionally override the value without having to write two functions?
Better description of the issue:
define sshauthkeys::helper ($user,$ensure='present', $target='') {
ssh_authorized_key { "puppet: ${name2} ${user}":
// etc etc...
target = $target
// ^--- Here, I'm forcing it to '' - how do I use the puppet
// built-in derivation, and only override optionally?
}
}
In this case, setting
target => undef
is the same thing as not specifying it at all, so you can write your wrapper like this: