On 13/04/16 03:31, Garrett Honeycutt wrote:
On 4/12/16 2:53 PM, Mike Reed wrote:
Hello all,
I've recently experienced some inconsistencies around referencing
Boolean values within a puppet manifest. We've written some custom
Boolean facts and we look to the true/false values within our manifests
to help make decisions on what should or shouldn't be done.
Hi Mike,
Booleans such as true vs. stringified booleans such as 'true' have long
been a sore spot within the Puppet ecosystem.
You want to set stringify_facts = false in your puppet.conf. This will
allow you to have other data types as facts such as booleans, arrays,
and hashes.
Recommend using this design pattern to deal with stringified booleans in
Puppet v3.
if is_string($my_param) == true {
$my_param_bool = str2bool($my_param)
} else {
$my_param_bool = $my_param
}
validate_bool($my_param_bool)
So given the param, $my_param, this will ensure it is an actual boolean.
In your code you reference $my_param_bool instead of $my_param.
From 4.5.0 (coming soon) the above example can be written like this:
$my_param_bool = Boolean($my_param)
Although in 4.x booleans are most likely already of Boolean type.
Best
- henrik
--
Visit my Blog "Puppet on the Edge"
http://puppet-on-the-edge.blogspot.se/
--
You received this message because you are subscribed to the Google Groups "Puppet
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/570F7F84.3030703%40puppetlabs.com.
For more options, visit https://groups.google.com/d/optout.