Details
-
Bug
-
Status: Resolved
-
Normal
-
Resolution: Fixed
-
None
-
None
Description
The stdlib getparam function does not behave as expected.
https://forge.puppetlabs.com/puppetlabs/stdlib#getparam
Issues:
- getparam() does not return false
- getparam() does not return parameter defaults
Expected behavior:
- getparam() should return the values of the parameters as they will be used.
- If that is not possible, the behavior should be documented
Current behavior:
- getparam() returns undef if the param is not specified in the resource declaration
- getparam() returns undef iif a parameter is specified as false, the function
Example code:
/tmp/test.pp
define my::example_resource(
|
$param1,
|
$param2,
|
$param3 = 'foo') {
|
}
|
my::example_resource { "example_resource_instance":
|
param1 => true,
|
param2 => false,
|
}
|
|
$value1=getparam(My::Example_resource["example_resource_instance"], "param1")
|
#validate_bool($value)
|
notify{"Value1: ${value1}":}
|
if $value1 == undef { notify{"Value1: undef":} }
|
|
$value2=getparam(My::Example_resource["example_resource_instance"], "param2")
|
notify{"Value2: ${value2}":}
|
if $value2 == undef { notify{"Value2: undef":} }
|
|
$value3=getparam(My::Example_resource["example_resource_instance"], "param3")
|
notify{"Value3: ${value3}":}
|
if $value3 == undef { notify{"Value3: undef":} }
|
|
$value4 = false
|
notify{"Value4: ${value4}":}
|
if $value4 == undef { notify{"Value4: undef":} }
|
Current result:
puppet apply /tmp/test.pp --modulepath=/etc/puppet/modules/
Notice: Value1: true
|
Notice: Value2:
|
Notice: Value2: undef
|
Notice: Value3:
|
Notice: Value3: undef
|
Notice: Value4: false
|
Puppet Version: 3.8.4
Attachments
Issue Links
- duplicates
-
MODULES-3933 stdlib: Unexpected result from getparam if param is false
-
- Resolved
-