| Puppet Version: 5.5.10 Puppet Server Version: N/A OS Name/Version: Debian 10.3
$ cat testcase.pp |
define resource($key = $name) { |
if($key == undef ){ |
warning("Case 1") |
} else { |
warning("Case 2") |
} |
} |
resource{'blub': |
key => undef |
} |
$ puppet apply testcase.pp
|
Desired Behavior:
Warning: Scope(Resource[blub]): Case 1
|
Actual Behavior:
Warning: Scope(Resource[blub]): Case 2
|
The behavior seems to be kind-of intended: From the docs: The undef value is useful for testing whether a variable has been set. Also, you can use it to un-set resource attributes that have inherited values from a resource default, causing the attribute to be unmanaged. So do I see this correctly that there is no way to pass "undef" to a resource which has a default assigned to the specific parameter? Because it would seem natural to me, to have a resource, with an optional parameter, that has some default value, with the option to un-set this default value on a per-instance basis. |