It seems puppet thinks that variables evaluate to true even when they are explicitly set to false in hiera YAML. In my searching it seems like this should be fixed but with hiera 1.2.1 and puppet 3.2.1 I''m still seeing this. In my YAML I have: # Java directives java : enable_jdk : false # Install the JDK as well as the JRE enable_v6 : true # Install Java 6 enable_v7 : false # Install Java 7 openjdk : true # Install OpenJDK sun : false # Install Sun And in one of my manifests I do something like: class java::install ( $parameters = hiera(''java'', []), ) { if $parameters[''openjdk''] == true { if $parameters[''enable_v6''] == true and $java::params::openjdk_6_jre { package { $java::params::openjdk_6_jre: ensure => latest, } if $parameters[''enable_jdk''] == true and $java::params::openjdk_6_jdk { package { $java::params::openjdk_6_jdk: ensure => latest, } } } … No matter what it thinks it should install the JDK package even though the parameter is set to false. I''ve tried setting it 0, False, n, and N and it always evaluates to true. Is this a known bug and if so is there a workaround? -- 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.
http://projects.puppetlabs.com/issues/17105 Hiera booleans are broken -- explicit false value registers as lookup failure On Jun 5, 2013, at 4:52 PM, Ti Leggett wrote:> It seems puppet thinks that variables evaluate to true even when they are explicitly set to false in hiera YAML. > > In my searching it seems like this should be fixed but with hiera 1.2.1 and puppet 3.2.1 I''m still seeing this. > > In my YAML I have: > > # Java directives > java : > enable_jdk : false # Install the JDK as well as the JRE > enable_v6 : true # Install Java 6 > enable_v7 : false # Install Java 7 > openjdk : true # Install OpenJDK > sun : false # Install Sun > > > And in one of my manifests I do something like: > > class java::install ( > $parameters = hiera(''java'', []), > ) { > if $parameters[''openjdk''] == true { > if $parameters[''enable_v6''] == true and $java::params::openjdk_6_jre { > package { $java::params::openjdk_6_jre: > ensure => latest, > } > if $parameters[''enable_jdk''] == true and $java::params::openjdk_6_jdk { > package { $java::params::openjdk_6_jdk: > ensure => latest, > } > } > } > … > > No matter what it thinks it should install the JDK package even though the parameter is set to false. I''ve tried setting it 0, False, n, and N and it always evaluates to true. Is this a known bug and if so is there a workaround? > > -- > 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.
Hm, that bug says it was a duplicate of 17474 and 17474 was revolved in 3.2.0-rc1. Do I have a variant of the bug that''s still residual? On Jun 5, 2013, at 7:12 PM, Dan White <ygor@comcast.net> wrote:> http://projects.puppetlabs.com/issues/17105 > Hiera booleans are broken -- explicit false value registers as lookup failure > > On Jun 5, 2013, at 4:52 PM, Ti Leggett wrote: > >> It seems puppet thinks that variables evaluate to true even when they are explicitly set to false in hiera YAML. >> >> In my searching it seems like this should be fixed but with hiera 1.2.1 and puppet 3.2.1 I''m still seeing this. >> >> In my YAML I have: >> >> # Java directives >> java : >> enable_jdk : false # Install the JDK as well as the JRE >> enable_v6 : true # Install Java 6 >> enable_v7 : false # Install Java 7 >> openjdk : true # Install OpenJDK >> sun : false # Install Sun >> >> >> And in one of my manifests I do something like: >> >> class java::install ( >> $parameters = hiera(''java'', []), >> ) { >> if $parameters[''openjdk''] == true { >> if $parameters[''enable_v6''] == true and $java::params::openjdk_6_jre { >> package { $java::params::openjdk_6_jre: >> ensure => latest, >> } >> if $parameters[''enable_jdk''] == true and $java::params::openjdk_6_jdk { >> package { $java::params::openjdk_6_jdk: >> ensure => latest, >> } >> } >> } >> … >> >> No matter what it thinks it should install the JDK package even though the parameter is set to false. I''ve tried setting it 0, False, n, and N and it always evaluates to true. Is this a known bug and if so is there a workaround? >> >> -- >> 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.
I may have found the problem: Add the following block of code - you will need to have the puppet-forge module stdlib installed -- and see what it does class java::install ( $parameters = hiera(''java'', []), ) { # ------------------------- start include stdlib if is_hash ( $parameters ) { notify { "It is a hash" : } } else { notify { "It is NOT a hash" : } } if $parameters { $hashkeez = keys ( $parameters ) notify { [ $hashkeez ]: message => "Key", } } # ------------------------- end if $parameters[''openjdk''] == true { if $parameters[''enable_v6''] == true and $java::params::openjdk_6_jre { package { $java::params::openjdk_6_jre: ensure => latest, On Wednesday, June 5, 2013 4:52:24 PM UTC-4, Ti Leggett wrote:> > It seems puppet thinks that variables evaluate to true even when they are > explicitly set to false in hiera YAML. > > In my searching it seems like this should be fixed but with hiera 1.2.1 > and puppet 3.2.1 I''m still seeing this. > > In my YAML I have: > > # Java directives > java : > enable_jdk : false # Install the JDK as well as the JRE > enable_v6 : true # Install Java 6 > enable_v7 : false # Install Java 7 > openjdk : true # Install OpenJDK > sun : false # Install Sun > > > And in one of my manifests I do something like: > > class java::install ( > $parameters = hiera(''java'', []), > ) { > if $parameters[''openjdk''] == true { > if $parameters[''enable_v6''] == true and > $java::params::openjdk_6_jre { > package { $java::params::openjdk_6_jre: > ensure => latest, > } > if $parameters[''enable_jdk''] == true and > $java::params::openjdk_6_jdk { > package { $java::params::openjdk_6_jdk: > ensure => latest, > } > } > } > … > > No matter what it thinks it should install the JDK package even though the > parameter is set to false. I''ve tried setting it 0, False, n, and N and it > always evaluates to true. Is this a known bug and if so is there a > workaround? > >-- 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.
Here''s what comes back from that. Info: Applying configuration version ''1370635086'' Notice: /Stage[main]/Java::Install/Notify[enable_v7]/message: current_value absent, should be Key (noop) Notice: /Stage[main]/Java::Install/Notify[enable_v6]/message: current_value absent, should be Key (noop) Notice: /Stage[main]/Java::Install/Notify[sun]/message: current_value absent, should be Key (noop) Notice: /Stage[main]/Java::Install/Notify[openjdk]/message: current_value absent, should be Key (noop) Notice: /Stage[main]/Java::Install/Package[java-1.6.0-openjdk-devel]/ensure: current_value absent, should be latest (noop) Notice: /Stage[main]/Java::Install/Notify[It is a hash]/message: current_value absent, should be It is a hash (noop) Notice: /Stage[main]/Java::Install/Notify[enable_jdk]/message: current_value absent, should be Key (noop) Notice: Class[Java::Install]: Would have triggered ''refresh'' from 7 events Notice: Finished catalog run in 27.52 seconds On Jun 6, 2013, at 10:22 AM, Ygor <ygor@comcast.net> wrote:> I may have found the problem: > > Add the following block of code - you will need to have the puppet-forge module stdlib installed -- and see what it does > > class java::install ( > $parameters = hiera(''java'', []), > ) { > > # ------------------------- start > include stdlib > > if is_hash ( $parameters ) { > notify { "It is a hash" : } > } else { > notify { "It is NOT a hash" : } > } > > if $parameters { > $hashkeez = keys ( $parameters ) > notify { [ $hashkeez ]: > message => "Key", > } > } > # ------------------------- end > > if $parameters[''openjdk''] == true { > if $parameters[''enable_v6''] == true and $java::params::openjdk_6_jre { > package { $java::params::openjdk_6_jre: > ensure => latest, > > > On Wednesday, June 5, 2013 4:52:24 PM UTC-4, Ti Leggett wrote: > It seems puppet thinks that variables evaluate to true even when they are explicitly set to false in hiera YAML. > > In my searching it seems like this should be fixed but with hiera 1.2.1 and puppet 3.2.1 I''m still seeing this. > > In my YAML I have: > > # Java directives > java : > enable_jdk : false # Install the JDK as well as the JRE > enable_v6 : true # Install Java 6 > enable_v7 : false # Install Java 7 > openjdk : true # Install OpenJDK > sun : false # Install Sun > > > And in one of my manifests I do something like: > > class java::install ( > $parameters = hiera(''java'', []), > ) { > if $parameters[''openjdk''] == true { > if $parameters[''enable_v6''] == true and $java::params::openjdk_6_jre { > package { $java::params::openjdk_6_jre: > ensure => latest, > } > if $parameters[''enable_jdk''] == true and $java::params::openjdk_6_jdk { > package { $java::params::openjdk_6_jdk: > ensure => latest, > } > } > } > … > > No matter what it thinks it should install the JDK package even though the parameter is set to false. I''ve tried setting it 0, False, n, and N and it always evaluates to true. Is this a known bug and if so is there a workaround? > > > -- > 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.
A couple of things: $parameters is supposed to end up as a hash, right ? You are setting a default value of an empty array ! $parameters = hiera(''java'', []), Try changing ‘java’ to something it will not find and see the errors you get. That is how I discovered it. My additional code shows that the hash is getting into your manifest, but it needs to be extended a bit to show the values of the hash. How about using another stdlib function like this: notify { [ join_keys_to_values ( $parameters, “ = “ ) ]: } I plan to try this myself on Monday. Next, there is this line: if $parameters[''enable_v6''] == true and $java::params::openjdk_6_jre { You need to verify the value of "$java::params::openjdk_6_jre” -- it is not in the example YAML -- and then you need to verify that your logic/syntax is actually doing what you want. This should help: http://docs.puppetlabs.com/puppet/3/reference/lang_datatypes.html#automatic-conversion-to-boolean On Jun 7, 2013, at 4:00 PM, Ti Leggett wrote:> Here''s what comes back from that. > > Info: Applying configuration version ''1370635086'' > Notice: /Stage[main]/Java::Install/Notify[enable_v7]/message: current_value absent, should be Key (noop) > Notice: /Stage[main]/Java::Install/Notify[enable_v6]/message: current_value absent, should be Key (noop) > Notice: /Stage[main]/Java::Install/Notify[sun]/message: current_value absent, should be Key (noop) > Notice: /Stage[main]/Java::Install/Notify[openjdk]/message: current_value absent, should be Key (noop) > Notice: /Stage[main]/Java::Install/Package[java-1.6.0-openjdk-devel]/ensure: current_value absent, should be latest (noop) > Notice: /Stage[main]/Java::Install/Notify[It is a hash]/message: current_value absent, should be It is a hash (noop) > Notice: /Stage[main]/Java::Install/Notify[enable_jdk]/message: current_value absent, should be Key (noop) > Notice: Class[Java::Install]: Would have triggered ''refresh'' from 7 events > Notice: Finished catalog run in 27.52 seconds > > On Jun 6, 2013, at 10:22 AM, Ygor <ygor@comcast.net> wrote: > >> I may have found the problem: >> >> Add the following block of code - you will need to have the puppet-forge module stdlib installed -- and see what it does >> >> class java::install ( >> $parameters = hiera(''java'', []), >> ) { >> >> # ------------------------- start >> include stdlib >> >> if is_hash ( $parameters ) { >> notify { "It is a hash" : } >> } else { >> notify { "It is NOT a hash" : } >> } >> >> if $parameters { >> $hashkeez = keys ( $parameters ) >> notify { [ $hashkeez ]: >> message => "Key", >> } >> } >> # ------------------------- end >> >> if $parameters[''openjdk''] == true { >> if $parameters[''enable_v6''] == true and $java::params::openjdk_6_jre { >> package { $java::params::openjdk_6_jre: >> ensure => latest, >> >> >> On Wednesday, June 5, 2013 4:52:24 PM UTC-4, Ti Leggett wrote: >> It seems puppet thinks that variables evaluate to true even when they are explicitly set to false in hiera YAML. >> >> In my searching it seems like this should be fixed but with hiera 1.2.1 and puppet 3.2.1 I''m still seeing this. >> >> In my YAML I have: >> >> # Java directives >> java : >> enable_jdk : false # Install the JDK as well as the JRE >> enable_v6 : true # Install Java 6 >> enable_v7 : false # Install Java 7 >> openjdk : true # Install OpenJDK >> sun : false # Install Sun >> >> >> And in one of my manifests I do something like: >> >> class java::install ( >> $parameters = hiera(''java'', []), >> ) { >> if $parameters[''openjdk''] == true { >> if $parameters[''enable_v6''] == true and $java::params::openjdk_6_jre { >> package { $java::params::openjdk_6_jre: >> ensure => latest, >> } >> if $parameters[''enable_jdk''] == true and $java::params::openjdk_6_jdk { >> package { $java::params::openjdk_6_jdk: >> ensure => latest, >> } >> } >> } >> … >> >> No matter what it thinks it should install the JDK package even though the parameter is set to false. I''ve tried setting it 0, False, n, and N and it always evaluates to true. Is this a known bug and if so is there a workaround? >> >> >> -- >> 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.
Responses inline. On Jun 7, 2013, at 10:37 PM, Dan White <ygor@comcast.net> wrote:> A couple of things: > > $parameters is supposed to end up as a hash, right ? > You are setting a default value of an empty array ! > > $parameters = hiera(''java'', []), > > Try changing ‘java’ to something it will not find and see the errors you get. That is how I discovered it.The second value to hiera() (and hiera_hash() )is a default value to use in case the key java isn''t found in hiera. I do this just to make sure that $parameters is a hash even if it''s empty.> My additional code shows that the hash is getting into your manifest, but it needs to be extended a bit to show the values of the hash. > How about using another stdlib function like this: > > notify { [ join_keys_to_values ( $parameters, “ = “ ) ]: } > > I plan to try this myself on Monday.As you can see from notify below, $parameters is a hash: Notice: /Stage[main]/Java::Install/Notify[It is a hash]/message: current_value absent, should be It is a hash (noop)> Next, there is this line: > if $parameters[''enable_v6''] == true and $java::params::openjdk_6_jre { > > You need to verify the value of "$java::params::openjdk_6_jre” -- it is not in the example YAML -- and then you need to verify that your logic/syntax is actually doing what you want.$java::params::openjdk_6_jre is a variable set in the java::params class: $ cat java/manifests/params.pp class java::params ( $parameters = hiera_hash(''java'', []), ) { case $::osfamily { ''Debian'': { $openjdk_6_jdk = [''openjdk-6-jdk''] $openjdk_6_jre = [''openjdk-6-jre''] $openjdk_7_jdk = [''openjdk-7-jdk''] $openjdk_7_jre = [''openjdk-7-jre''] $sum_6_jdk = [''sun-java6-jdk''] $sun_6_jre = [''sun-java6-jre''] } ''RedHat'': { $openjdk_6_jdk = [''java-1.6.0-openjdk''] $openjdk_6_jre = [''java-1.6.0-openjdk-devel''] $openjdk_7_jdk = [''java-1.7.0-openjdk''] $openjdk_7_jre = [''java-1.7.0-openjdk-devel''] } default: { fail("Unsupported platform: $osfamily") } } }> This should help: > http://docs.puppetlabs.com/puppet/3/reference/lang_datatypes.html#automatic-conversion-to-booleanThanks for the pointer!> > On Jun 7, 2013, at 4:00 PM, Ti Leggett wrote: > >> Here''s what comes back from that. >> >> Info: Applying configuration version ''1370635086'' >> Notice: /Stage[main]/Java::Install/Notify[enable_v7]/message: current_value absent, should be Key (noop) >> Notice: /Stage[main]/Java::Install/Notify[enable_v6]/message: current_value absent, should be Key (noop) >> Notice: /Stage[main]/Java::Install/Notify[sun]/message: current_value absent, should be Key (noop) >> Notice: /Stage[main]/Java::Install/Notify[openjdk]/message: current_value absent, should be Key (noop) >> Notice: /Stage[main]/Java::Install/Package[java-1.6.0-openjdk-devel]/ensure: current_value absent, should be latest (noop) >> Notice: /Stage[main]/Java::Install/Notify[It is a hash]/message: current_value absent, should be It is a hash (noop) >> Notice: /Stage[main]/Java::Install/Notify[enable_jdk]/message: current_value absent, should be Key (noop) >> Notice: Class[Java::Install]: Would have triggered ''refresh'' from 7 events >> Notice: Finished catalog run in 27.52 seconds >>-- 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.
This but only applied to the hiera data bindings afaik, not to hiera function calls. On 6 June 2013 03:41, Ti Leggett <shingle@gmail.com> wrote:> Hm, that bug says it was a duplicate of 17474 and 17474 was revolved in > 3.2.0-rc1. Do I have a variant of the bug that''s still residual? > > > On Jun 5, 2013, at 7:12 PM, Dan White <ygor@comcast.net> wrote: > > > http://projects.puppetlabs.com/issues/17105 > > Hiera booleans are broken -- explicit false value registers as lookup > failure > > > > On Jun 5, 2013, at 4:52 PM, Ti Leggett wrote: > > > >> It seems puppet thinks that variables evaluate to true even when they > are explicitly set to false in hiera YAML. > >> > >> In my searching it seems like this should be fixed but with hiera 1.2.1 > and puppet 3.2.1 I''m still seeing this. > >> > >> In my YAML I have: > >> > >> # Java directives > >> java : > >> enable_jdk : false # Install the JDK as well as the JRE > >> enable_v6 : true # Install Java 6 > >> enable_v7 : false # Install Java 7 > >> openjdk : true # Install OpenJDK > >> sun : false # Install Sun > >> > >> > >> And in one of my manifests I do something like: > >> > >> class java::install ( > >> $parameters = hiera(''java'', []), > >> ) { > >> if $parameters[''openjdk''] == true { > >> if $parameters[''enable_v6''] == true and > $java::params::openjdk_6_jre { > >> package { $java::params::openjdk_6_jre: > >> ensure => latest, > >> } > >> if $parameters[''enable_jdk''] == true and > $java::params::openjdk_6_jdk { > >> package { $java::params::openjdk_6_jdk: > >> ensure => latest, > >> } > >> } > >> } > >> … > >> > >> No matter what it thinks it should install the JDK package even though > the parameter is set to false. I''ve tried setting it 0, False, n, and N and > it always evaluates to true. Is this a known bug and if so is there a > workaround? > >> > >> -- > >> 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. > > >-- Erik Dalén -- 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.