Hi... I''ve been trying to set up boolean values in Hiera, but with no luck. For example, I''m using puppetlabs-haproxy module, and this is a code snippet: class haproxy ( $manage_service = true, ... ) inherits haproxy::params { ... if $manage_service { } } Now, this is how I set up values in hiera: haproxy::manage_service: false But, it seems that $manage_service is always true... I tried by single quoting ''false'', capital letter False, but nothing helps... Only thing so far I''ve found out is to change the manifest code to look like this: if $manage_service == ''true'' { } Any ideas? -- 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 puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Getting booleans from hiera to puppet is not currently not functioning like you would expect. There is a bug reported for it and they are working on it but it''s still in progress last I looked. On 6 March 2013 06:08, Jakov Sosic <jsosic@srce.hr> wrote:> Hi... > > I''ve been trying to set up boolean values in Hiera, but with no luck. > > For example, I''m using puppetlabs-haproxy module, and this is a code > snippet: > > class haproxy ( > $manage_service = true, > ... > ) inherits haproxy::params { > ... > > if $manage_service { > } > } > > Now, this is how I set up values in hiera: > > haproxy::manage_service: false > > > But, it seems that $manage_service is always true... I tried by single > quoting ''false'', capital letter False, but nothing helps... > > Only thing so far I''ve found out is to change the manifest code to look > like this: > > if $manage_service == ''true'' { > } > > > Any ideas? > > -- > 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 puppet-users+unsubscribe@googlegroups.com. > To post to this group, send email to puppet-users@googlegroups.com. > Visit this group at http://groups.google.com/group/puppet-users?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > >-- 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 puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
On Wed, Mar 06, 2013 at 01:29:29PM +1000, Peter Brown wrote:> Getting booleans from hiera to puppet is not currently not functioning like > you would expect. > There is a bug reported for it and they are working on it but it''s still in > progress last I looked. > >Would this > http://projects.puppetlabs.com/issues/16178 be the report? If so, I''m really hoping that it''s solved in 3.0.2 as running into the same issue myself :( -- Richard Clark richard@fohnet.co.uk
I am running 3.1.0 and hiera booleans appear to be working fine. - Keith On 6 March 2013 09:15, Richard Clark <richard@fohnet.co.uk> wrote:> On Wed, Mar 06, 2013 at 01:29:29PM +1000, Peter Brown wrote: > > Getting booleans from hiera to puppet is not currently not functioning > like > > you would expect. > > There is a bug reported for it and they are working on it but it''s still > in > > progress last I looked. > > > > > > Would this > http://projects.puppetlabs.com/issues/16178 be the report? > If so, I''m really hoping that it''s solved in 3.0.2 as running into the > same issue myself :( > > -- > Richard Clark > richard@fohnet.co.uk >-- 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 puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
On 03/06/2013 10:59 AM, Keith Burdis wrote:> I am running 3.1.0 and hiera booleans appear to be working fine.I am running 3.1.0 and still have problems... -- 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 puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Last I tried I still had problems in 3.1.0. On 7 March 2013 02:20, Jakov Sosic <jsosic@srce.hr> wrote:> On 03/06/2013 10:59 AM, Keith Burdis wrote: > > I am running 3.1.0 and hiera booleans appear to be working fine. > > I am running 3.1.0 and still have problems... > > -- > 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 puppet-users+unsubscribe@googlegroups.com. > To post to this group, send email to puppet-users@googlegroups.com. > Visit this group at http://groups.google.com/group/puppet-users?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > >-- 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 puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
I''m on 3.1, and I''m finding that "true" works as expected, but "false" does not! I think "false" is interpreted as "undef" or so, thus taking value from the module''s default params On Tuesday, March 5, 2013 10:08:44 PM UTC+2, Jakov Sosic wrote:> > Hi... > > I''ve been trying to set up boolean values in Hiera, but with no luck. > > For example, I''m using puppetlabs-haproxy module, and this is a code > snippet: > > class haproxy ( > $manage_service = true, > ... > ) inherits haproxy::params { > ... > > if $manage_service { > } > } > > Now, this is how I set up values in hiera: > > haproxy::manage_service: false > > > But, it seems that $manage_service is always true... I tried by single > quoting ''false'', capital letter False, but nothing helps... > > Only thing so far I''ve found out is to change the manifest code to look > like this: > > if $manage_service == ''true'' { > } > > > Any ideas? > >-- 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 puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
On Thursday, March 7, 2013 6:38:52 AM UTC-6, Ahmed Kamal wrote:> > I''m on 3.1, and I''m finding that "true" works as expected, but "false" > does not! I think "false" is interpreted as "undef" or so, thus taking > value from the module''s default params >False is being treated as the lookup function itself returning false - which then means nil is used and the next level of looking for a default (either the next level of hierarchy, the next backend or the defaults defined with the class. I think this is supposed to be fixed in hiera 1.2, which just had rc1 released, but I am not positive.> > On Tuesday, March 5, 2013 10:08:44 PM UTC+2, Jakov Sosic wrote: >> >> Hi... >> >> I''ve been trying to set up boolean values in Hiera, but with no luck. >> >> For example, I''m using puppetlabs-haproxy module, and this is a code >> snippet: >> >> class haproxy ( >> $manage_service = true, >> ... >> ) inherits haproxy::params { >> ... >> >> if $manage_service { >> } >> } >> >> Now, this is how I set up values in hiera: >> >> haproxy::manage_service: false >> >> >> But, it seems that $manage_service is always true... I tried by single >> quoting ''false'', capital letter False, but nothing helps... >> >> Only thing so far I''ve found out is to change the manifest code to look >> like this: >> >> if $manage_service == ''true'' { >> } >> >> >> Any ideas? >> >>-- 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 puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Jakov Sosic
2013-Mar-07 19:28 UTC
Re: [Puppet Users] Re: Boolean in hiera... problems again
On 03/07/2013 02:41 PM, llowder wrote:> > > On Thursday, March 7, 2013 6:38:52 AM UTC-6, Ahmed Kamal wrote: > > I''m on 3.1, and I''m finding that "true" works as expected, but > "false" does not! I think "false" is interpreted as "undef" or so, > thus taking value from the module''s default params > > > False is being treated as the lookup function itself returning false - > which then means nil is used and the next level of looking for a default > (either the next level of hierarchy, the next backend or the defaults > defined with the class. > > I think this is supposed to be fixed in hiera 1.2, which just had rc1 > released, but I am not positive.A-ha! Thank you guys, so it''s not me doing something wrong after all... -- 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 puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Nick Fagerlund
2013-Mar-07 20:43 UTC
Re: [Puppet Users] Re: Boolean in hiera... problems again
On Thursday, March 7, 2013 11:28:23 AM UTC-8, Jakov Sosic wrote:> > On 03/07/2013 02:41 PM, llowder wrote: > > > > > > On Thursday, March 7, 2013 6:38:52 AM UTC-6, Ahmed Kamal wrote: > > > > I''m on 3.1, and I''m finding that "true" works as expected, but > > "false" does not! I think "false" is interpreted as "undef" or so, > > thus taking value from the module''s default params >Yeah it''s definitely a bug, but I think it''s http://projects.puppetlabs.com/issues/17105 -- not sure when it''ll be fixed, but I know they''re working on it and consider it serious. If you need it to work today, you can use the "sloppy bools" pattern, and use a string (instead of a real bool) in your hiera data: class myclass ($myparam) { $myparam_real = str2bool("$myparam") #... use $myparam_real everywhere below here. } --- myclass::myparam: "false" This will make it so $myparam can be a string, a real boolean, or a number (0/1), and still work fine. Note the quotes in the str2bool call; those make it so you can later change the hiera data to a real bool (after the bug is fixed) without changing your code. -- 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 puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Peter Brown
2013-Mar-07 23:16 UTC
Re: [Puppet Users] Re: Boolean in hiera... problems again
On 8 March 2013 06:43, Nick Fagerlund <nick.fagerlund@puppetlabs.com> wrote:> > > On Thursday, March 7, 2013 11:28:23 AM UTC-8, Jakov Sosic wrote: >> >> On 03/07/2013 02:41 PM, llowder wrote: >> > >> > >> > On Thursday, March 7, 2013 6:38:52 AM UTC-6, Ahmed Kamal wrote: >> > >> > I''m on 3.1, and I''m finding that "true" works as expected, but >> > "false" does not! I think "false" is interpreted as "undef" or so, >> > thus taking value from the module''s default params >> > > Yeah it''s definitely a bug, but I think it''s > http://projects.puppetlabs.com/issues/17105 -- not sure when it''ll be > fixed, but I know they''re working on it and consider it serious. > > If you need it to work today, you can use the "sloppy bools" pattern, and > use a string (instead of a real bool) in your hiera data: > > class myclass ($myparam) { > $myparam_real = str2bool("$myparam") > #... use $myparam_real everywhere below here. > } > > --- > myclass::myparam: "false" > > This will make it so $myparam can be a string, a real boolean, or a number > (0/1), and still work fine. Note the quotes in the str2bool call; those > make it so you can later change the hiera data to a real bool (after the > bug is fixed) without changing your code.Awesome! I was attempting to think of a quick fix for the problem but hadn''t gotten around to it. My solution was to set the vars in each node definition but this idea is nicer Thanks Nick!> > > -- > 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 puppet-users+unsubscribe@googlegroups.com. > To post to this group, send email to puppet-users@googlegroups.com. > Visit this group at http://groups.google.com/group/puppet-users?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > >-- 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 puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Nick Fagerlund
2013-Mar-08 00:57 UTC
Re: [Puppet Users] Re: Boolean in hiera... problems again
OH, I should mention: the str2bool function is from puppetlabs/stdlib (http://forge.puppetlabs.com/puppetlabs/stdlib) On Thursday, March 7, 2013 3:16:32 PM UTC-8, Pete wrote:> > Awesome! > I was attempting to think of a quick fix for the problem but hadn''t gotten > around to it. > My solution was to set the vars in each node definition but this idea is > nicer > > Thanks Nick! > >-- 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 puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Richard Clark
2013-Mar-08 15:55 UTC
Re: [Puppet Users] Re: Boolean in hiera... problems again
On Thu, Mar 07, 2013 at 12:43:26PM -0800, Nick Fagerlund wrote:> > Yeah it''s definitely a bug, but I think it''s > http://projects.puppetlabs.com/issues/17105 -- not sure when it''ll be > fixed, but I know they''re working on it and consider it serious. > > If you need it to work today, you can use the "sloppy bools" pattern, and > use a string (instead of a real bool) in your hiera data: > > class myclass ($myparam) { > $myparam_real = str2bool("$myparam") > #... use $myparam_real everywhere below here. > } > > --- > myclass::myparam: "false" > > This will make it so $myparam can be a string, a real boolean, or a number > (0/1), and still work fine. Note the quotes in the str2bool call; those > make it so you can later change the hiera data to a real bool (after the > bug is fixed) without changing your code.Yeah that appears to be the bug report, and is to be limited to auto-lookups from parameterized classes/data binding. In the YAML spec, similar to many languages (including puppet DSL), true/false must be unquoted. Otherwise ''true'' = a string containing the word true, which evaluates to true, as does the string ''false''. Classy workaround sir, I will apply liberally. -- Richard Clark richard@fohnet.co.uk