Reputation: 154
The following code example is purely academical but it illustrates my question pretty well.
define touch($file=$title, $unless='/bin/false') {
exec { "/bin/touch ${file}": unless => $unless }
}
If I define my own resource type that wraps another exec resource and I want to add an optional "unless" condition that I - if set - pass to the optional "unless" condiftion of exec - do I have to preset the field with '/bin/false'?
My understanding is that for each catalog run and all uses of this custom ressource type this resource's unless check will then spawn a bash process running '/bin/false' if the unless field of "touch" hasn't been set .
What I actually intend is not to do any "unless" check at all if the field hasn't been set - including calling "/bin/false".
Any thoughts? Thanks!
Upvotes: 0
Views: 1204
Reputation: 42048
Use undef instead of '/bin/false', unless will run only if it is set:
define touch($file=$title, $unless=undef) {
exec { "/bin/touch ${file}": unless => $unless }
}
Upvotes: 5