Jan
2011-Apr-01 09:19 UTC
[Puppet Users] if statement: ''true'' from left operand of ''in'' expression is not a string
Hi *, using the following snippet of code .. ------------------------------------------------------------------------ [...] 7 if ! ($installplugins in [ true, false ]) { 8 fail("nrpe installplugins parameter must be true or false") 9 } [...] 24 if $installplugins == true { 25 package { ["mypluginpackage", 26 ensure => installed } 27 } [...] ------------------------------------------------------------------------ .. puppet throws the following error: ------------------------------------------------------------------------ err: Could not retrieve catalog from remote server: Error 400 on SERVER: ''true'' from left operand of ''in'' expression is not a string at /etc/puppet/manifests/classes/monitoring.pp:7 on node puppet ------------------------------------------------------------------------ This snippet of code I got from the puppet style-guide: http://docs.puppetlabs.com/guides/style_guide.html#class-inheritance -> see the bluetooth class example Any ideas? What am I missing? Btw. I''m running a self-build version of puppet 2.6.4 without additional patches ... Many thanks Jan -- | Jan Dennis Bungart () ascii ribbon campaign | Open Source Technician /\ - against HTML e-mail | System- and Network Engineering | +49-(0)-160-90191003 -- 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.
Denmat
2011-Apr-01 11:58 UTC
Re: [Puppet Users] if statement: ''true'' from left operand of ''in'' expression is not a string
Hi, Change> if $installplugins == true { > 25 package { ["mypluginpackage", > 26 ensure => installed } > 27 }To this> if $installplugins { > 25 package { ["mypluginpackage", > 26 ensure => installed } > 27 }Cheers, On 01/04/2011, at 20:19, Jan <jan@agetty.de> wrote:> Hi *, > > using the following snippet of code .. > > ------------------------------------------------------------------------ > [...] > 7 if ! ($installplugins in [ true, false ]) { > 8 fail("nrpe installplugins parameter must be true or false") > 9 } > [...] > 24 if $installplugins == true { > 25 package { ["mypluginpackage", > 26 ensure => installed } > 27 } > [...] > ------------------------------------------------------------------------ > > .. puppet throws the following error: > > ------------------------------------------------------------------------ > err: Could not retrieve catalog from remote server: Error 400 on SERVER: > ''true'' from left operand of ''in'' expression is not a string at > /etc/puppet/manifests/classes/monitoring.pp:7 on node puppet > ------------------------------------------------------------------------ > > This snippet of code I got from the puppet style-guide: > > http://docs.puppetlabs.com/guides/style_guide.html#class-inheritance > > -> see the bluetooth class example > > Any ideas? What am I missing? > > Btw. I''m running a self-build version of puppet 2.6.4 without additional > patches ... > > Many thanks > > Jan > > -- > > | Jan Dennis Bungart > () ascii ribbon campaign | Open Source Technician > /\ - against HTML e-mail | System- and Network Engineering > | +49-(0)-160-90191003 > > -- > 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. >-- 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.
Denmat
2011-Apr-01 12:05 UTC
Re: [Puppet Users] if statement: ''true'' from left operand of ''in'' expression is not a string
Sorry that''s probably a bit premature. Ignore me. On 01/04/2011, at 22:58, Denmat <tu2bgone@gmail.com> wrote:> Hi, > > Change > >> if $installplugins == true { >> 25 package { ["mypluginpackage", >> 26 ensure => installed } >> 27 } > > To this > >> if $installplugins { >> 25 package { ["mypluginpackage", >> 26 ensure => installed } >> 27 } > > > Cheers, > > On 01/04/2011, at 20:19, Jan <jan@agetty.de> wrote: > >> Hi *, >> >> using the following snippet of code .. >> >> ------------------------------------------------------------------------ >> [...] >> 7 if ! ($installplugins in [ true, false ]) { >> 8 fail("nrpe installplugins parameter must be true or false") >> 9 } >> [...] >> 24 if $installplugins == true { >> 25 package { ["mypluginpackage", >> 26 ensure => installed } >> 27 } >> [...] >> ------------------------------------------------------------------------ >> >> .. puppet throws the following error: >> >> ------------------------------------------------------------------------ >> err: Could not retrieve catalog from remote server: Error 400 on SERVER: >> ''true'' from left operand of ''in'' expression is not a string at >> /etc/puppet/manifests/classes/monitoring.pp:7 on node puppet >> ------------------------------------------------------------------------ >> >> This snippet of code I got from the puppet style-guide: >> >> http://docs.puppetlabs.com/guides/style_guide.html#class-inheritance >> >> -> see the bluetooth class example >> >> Any ideas? What am I missing? >> >> Btw. I''m running a self-build version of puppet 2.6.4 without additional >> patches ... >> >> Many thanks >> >> Jan >> >> -- >> >> | Jan Dennis Bungart >> () ascii ribbon campaign | Open Source Technician >> /\ - against HTML e-mail | System- and Network Engineering >> | +49-(0)-160-90191003 >> >> -- >> 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. >>-- 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.
Ben Hughes
2011-Apr-04 01:29 UTC
Re: [Puppet Users] if statement: ''true'' from left operand of ''in'' expression is not a string
On Fri, Apr 01, 2011 at 11:19:16AM +0200, Jan wrote:> Any ideas? What am I missing?If you quote the true/falses, it works. In the style guide, they''re being used as variables for setting options of a type: hasstatus => $trueorfalsevar. However, if you want to evaluate them, they need to be quoted I''m afraid. $installplugins = ''true'' if ! ($installplugins in [ ''true'', ''false'' ]) { fail("nrpe installplugins parameter must be true or false") } if $installplugins == ''true'' { notice( "I work, hurrah" ) } -- Ben Hughes || http://www.puppetlabs.com/ -- 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.
jcbollinger
2011-Apr-04 13:39 UTC
[Puppet Users] Re: if statement: ''true'' from left operand of ''in'' expression is not a string
On Apr 3, 8:29 pm, Ben Hughes <b...@puppetlabs.com> wrote:> On Fri, Apr 01, 2011 at 11:19:16AM +0200, Jan wrote: > > Any ideas? What am I missing? > > If you quote the true/falses, it works. > > In the style guide, they''re being used as variables for setting options of > a type: hasstatus => $trueorfalsevar. > > However, if you want to evaluate them, they need to be quoted I''m afraid. > > $installplugins = ''true'' > > if ! ($installplugins in [ ''true'', ''false'' ]) { > fail("nrpe installplugins parameter must be true or false") > > } > > if $installplugins == ''true'' { > notice( "I work, hurrah" ) > > }Curious. From the message, I would guess that this would (also) work: if ! ("$installplugins" in [ true, false ]) { fail("nrpe installplugins parameter must be true or false") } (Since it''s the *left* side of the in operator that Puppet complains about not being a string.) Of course, it''s quite inconsistent that if one assigns bareword true to a variable, one cannot subsequently compare that variable against the same value, or against an array that (appears to) contain that value. I call bug, and I recommend filing a ticket. John -- 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.