Reputation: 230
Is it possible to convert Boolean
variable to String
in Puppet
? I want to use it when replacing string. I can use conditional statement but maybe it is not necessary.
$variable = true
$my_string = "status _"
$string = regsubst($my_string, '_', $variable)
Something like this
Upvotes: 3
Views: 2543
Reputation: 5190
I'd recomend using the puppetlabs-stdlib function for this:
Converts a boolean to a string using optionally supplied arguments. The optional second and third arguments represent what true and false are converted to respectively. If only one argument is given, it is converted from a boolean to a string containing 'true' or 'false'.
Examples:bool2str(true) => 'true'
bool2str(true, 'yes', 'no') => 'yes'
bool2str(false, 't', 'f') => 'f'
Requires a single boolean as input. Type: rvalue.
Upvotes: 6