try:
if $enabled {
do it
}
if $enabled is false or undef then it won't do it.
--
Pietro Monteiro
Senior Developer
DECK Monitoring
115 W 8th Ave. Eugene, Oregon 97401
Office: 541-343-0110
www.deckmonitoring.com
then try:
if $foo == true or $foo == false {
class { 'doit': enabled => $enabled }
}
or:
case $foo {
true,false: { class { 'doit': enabled => $enabled } }
undef, '', false all evaluate to false. However the string "false"
evaluates to true.
> But if it's undef I don't even want to include the class.
>
> I'm guessing that if this is not a valid used syntax then I'll have to
> do something like:
>
> if $enabled == true or $enabled == false {
> }
>
I'm not sure it's a good idea to take advantage of this behavior, but
in theory you can set $enabled="true"|"false" and compare the string
value in the class instead of true, false.
Thanks,
Nan
Maybe this way?
$foo = "true"
if $foo in [ "true", "false" ] {
alert "foo!"
}
[12:41:25] $ puppet apply test.pp
alert: Scope(Class[main]): foo!
;)
You should raise a bug then.
I concur, the boolean semantics can be less than optimal.
Cheers,
Felix