cody@hawkhoststatus.com
2013-Feb-28 20:44 UTC
[Puppet Users] Issues with conditionals & Hiera
Hello everyone! I hope your Thursdays are going swimmingly! I''m having an issue with using data looked up via Hiera and using that in a conditional in my manifest. Here is a simple use-case where I simply cannot get it to work: http://pastie.org/private/gtplsiajmmrdhjie49bda# In this example the Hiera lookup is handling as expected - globally the cagefs_enabled variable is being returned as "false" and on the some.fqdn.com.yaml it''s being returned as "true". The notice() call right after the lookup confirms that the variable is being set properly. The issue is I cannot for the life of me to get that data to work in a conditional. I''ve tried string comparisons and simple binary ones (1==1, 0==0) to no luck. The IF statement simply isn''t being hit. Am I missing something obvious in this case? -- 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.
--- cagefs_enabled: - ''false'' should be ---cagefs_enabled: ''false'' You were creating an arrray named cagefs_enabled with the first element as true... Stefan - Zipkid - Goethals. On Thu, Feb 28, 2013 at 9:44 PM, <cody@hawkhoststatus.com> wrote:> Hello everyone! I hope your Thursdays are going swimmingly! > > I''m having an issue with using data looked up via Hiera and using that in > a conditional in my manifest. Here is a simple use-case where I simply > cannot get it to work: http://pastie.org/private/gtplsiajmmrdhjie49bda# > > In this example the Hiera lookup is handling as expected - globally the > cagefs_enabled variable is being returned as "false" and on the > some.fqdn.com.yaml it''s being returned as "true". The notice() call right > after the lookup confirms that the variable is being set properly. > > The issue is I cannot for the life of me to get that data to work in a > conditional. I''ve tried string comparisons and simple binary ones (1==1, > 0==0) to no luck. The IF statement simply isn''t being hit. > > Am I missing something obvious in this case? > > -- > 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.
Other folks have pointed out the fact that you made an array, but have you tried using true and false without the quotes ? I believe that will produce a proper Boolean value. “Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us.” Bill Waterson (Calvin & Hobbes) ----- Original Message ----- From: cody@hawkhoststatus.com To: puppet-users@googlegroups.com Sent: Thursday, February 28, 2013 3:44:39 PM Subject: [Puppet Users] Issues with conditionals & Hiera Hello everyone! I hope your Thursdays are going swimmingly! I''m having an issue with using data looked up via Hiera and using that in a conditional in my manifest. Here is a simple use-case where I simply cannot get it to work: http://pastie.org/private/gtplsiajmmrdhjie49bda# In this example the Hiera lookup is handling as expected - globally the cagefs_enabled variable is being returned as "false" and on the some.fqdn.com.yaml it''s being returned as "true". The notice() call right after the lookup confirms that the variable is being set properly. The issue is I cannot for the life of me to get that data to work in a conditional. I''ve tried string comparisons and simple binary ones (1==1, 0==0) to no luck. The IF statement simply isn''t being hit. Am I missing something obvious in this case? -- 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.
Clearly I have a firm grasp on YAML. That''d be the issue - thanks! For the record I tried all of the possible values (True, "true", 1) - obviously it was failing as it was an array as previously mentioned. On Thu, Feb 28, 2013 at 5:11 PM, Dan White <ygor@comcast.net> wrote:> Other folks have pointed out the fact that you made an array, but have you > tried using true and false without the quotes ? > I believe that will produce a proper Boolean value. > > “Sometimes I think the surest sign that intelligent life exists elsewhere > in the universe is that none of it has tried to contact us.” > Bill Waterson (Calvin & Hobbes) > > ------------------------------ > *From: *cody@hawkhoststatus.com > *To: *puppet-users@googlegroups.com > *Sent: *Thursday, February 28, 2013 3:44:39 PM > *Subject: *[Puppet Users] Issues with conditionals & Hiera > > > Hello everyone! I hope your Thursdays are going swimmingly! > > I''m having an issue with using data looked up via Hiera and using that in > a conditional in my manifest. Here is a simple use-case where I simply > cannot get it to work: http://pastie.org/private/gtplsiajmmrdhjie49bda# > > In this example the Hiera lookup is handling as expected - globally the > cagefs_enabled variable is being returned as "false" and on the > some.fqdn.com.yaml it''s being returned as "true". The notice() call right > after the lookup confirms that the variable is being set properly. > > The issue is I cannot for the life of me to get that data to work in a > conditional. I''ve tried string comparisons and simple binary ones (1==1, > 0==0) to no luck. The IF statement simply isn''t being hit. > > Am I missing something obvious in this case? > > -- > 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. > > >-- 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.
It may be worth noting that the notice() function printed the variable as a normal string (or seemingly) making it difficult to recognize the fact it was actually an array. I''m not sure if this is something that should be made obvious or not but it''s worth noting for anyone who lands on this via Google. On Thu, Feb 28, 2013 at 5:13 PM, Cody Robertson <cody@hawkhoststatus.com>wrote:> Clearly I have a firm grasp on YAML. That''d be the issue - thanks! > > For the record I tried all of the possible values (True, "true", 1) - > obviously it was failing as it was an array as previously mentioned. > > > On Thu, Feb 28, 2013 at 5:11 PM, Dan White <ygor@comcast.net> wrote: > >> Other folks have pointed out the fact that you made an array, but have >> you tried using true and false without the quotes ? >> I believe that will produce a proper Boolean value. >> >> “Sometimes I think the surest sign that intelligent life exists elsewhere >> in the universe is that none of it has tried to contact us.” >> Bill Waterson (Calvin & Hobbes) >> >> ------------------------------ >> *From: *cody@hawkhoststatus.com >> *To: *puppet-users@googlegroups.com >> *Sent: *Thursday, February 28, 2013 3:44:39 PM >> *Subject: *[Puppet Users] Issues with conditionals & Hiera >> >> >> Hello everyone! I hope your Thursdays are going swimmingly! >> >> I''m having an issue with using data looked up via Hiera and using that in >> a conditional in my manifest. Here is a simple use-case where I simply >> cannot get it to work: http://pastie.org/private/gtplsiajmmrdhjie49bda# >> >> In this example the Hiera lookup is handling as expected - globally the >> cagefs_enabled variable is being returned as "false" and on the >> some.fqdn.com.yaml it''s being returned as "true". The notice() call right >> after the lookup confirms that the variable is being set properly. >> >> The issue is I cannot for the life of me to get that data to work in a >> conditional. I''ve tried string comparisons and simple binary ones (1==1, >> 0==0) to no luck. The IF statement simply isn''t being hit. >> >> Am I missing something obvious in this case? >> >> -- >> 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. >> >> >> > >-- 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, February 28, 2013 4:20:43 PM UTC-6, Cody Robertson wrote:> > It may be worth noting that the notice() function printed the variable as > a normal string (or seemingly) making it difficult to recognize the fact it > was actually an array. I''m not sure if this is something that should be > made obvious or not but it''s worth noting for anyone who lands on this via > Google. > >Yes, the default stringification of an array is the concatenation of the stringifications of its elements. For a one-element array, that''s just the stringification of the single element. You should consider filing an enhancement ticket, but be aware that the existing behavior has enough historical inertia that it might be difficult to get it changed. John -- 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.