Skip to content

Instantly share code, notes, and snippets.

@jensk
Last active December 17, 2015 23:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jensk/5693370 to your computer and use it in GitHub Desktop.
Save jensk/5693370 to your computer and use it in GitHub Desktop.
Hiera boolean issue
# original class
class dnsmasq (
$service_enabled = true,
$service_boot = true,
$service_managed = true,
){
$service_ensure = $service_enabled ? {
false => stopped,
default => running
}
}
# Adjusted to work with hiera (automatic class paramater lookups)
# which doesnt allow for boolean fields like
#
# dnsmasq::service_enabled = false
#
# String as potential solution:
#
# dnsmasq::service_enabled = 'false'
#
# which would require patching like this:
#
class dnsmasq (
$service_enabled = true,
$service_boot = true,
$service_managed = true,
){
$service_ensure = str2bool($service_enabled) ? {
false => stopped,
default => running
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment