MBroderick@TDS
2012-Feb-14 23:07 UTC
[Puppet Users] using a boolean selector inside require always returns false
We are trying to conditionalize what is required by a resource... service { "xxx": ... require => $bool-var ? { true => [ list1 ], false => [ list2 ], } } But false always seems to get selected regardless of the value of bool- var (true or false). As a workaround, we did if $bool-var { $t = [ list1 ] } else { $t = [ list2 ] } service { ... ... require => $t } ...but prefer the previous more elegant declaration. Is this a bug? Known? (we are running 2.6.8 and I did not see any later release notes addressing this) _Mike -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Henrik Lindberg
2012-Feb-14 23:37 UTC
Re: [Puppet Users] using a boolean selector inside require always returns false
On 2012-15-02 24:07, MBroderick@TDS wrote:> We are trying to conditionalize what is required by a resource... > > service { "xxx": > ... > require => $bool-var ? { > true => [ list1 ], > false => [ list2 ], > } > } >is $bool-var really a boolean, or does it contain the text "true" or "false"? Guess what this prints out... if "false" { notice("false is true") } (Also note that hyphens in variable names only work in some versions, and will not be supported going forward. You can change the ''-'' to ''_''). The reason your first example produces undefined is that a string is neither boolean true nor false when comparing. The second example produces true for the string (with the meaning it is not undefined) - it will always be true unless $boolean-var is undefined. You can try $boolean-var == "true" ? { true => ..., false => ...} Regards - henrik -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.