How do I get get length of an array in puppet DSL? Doug -- 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.
On Wed, Aug 15, 2012 at 2:51 PM, Douglas Garstang <doug.garstang@gmail.com> wrote:> How do I get get length of an array in puppet DSL?Hi Doug, You can install the puppetlabs-stdlib module from the Forge and use the size function. Forge page: http://forge.puppetlabs.com/puppetlabs/stdlib The raw function code: https://github.com/puppetlabs/puppetlabs-stdlib/blob/master/lib/puppet/parser/functions/size.rb HTH, --Ryan> > Doug > > -- > 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.
On Wed, Aug 15, 2012 at 2:55 PM, Ryan Coleman <ryan@puppetlabs.com> wrote:> On Wed, Aug 15, 2012 at 2:51 PM, Douglas Garstang > <doug.garstang@gmail.com> wrote: >> How do I get get length of an array in puppet DSL? > > Hi Doug, > > You can install the puppetlabs-stdlib module from the Forge and use > the size function. >Ryan, No thanks. I''ve stopped using 3rd party modules. Providers don''t work with environments... at least I don''t think they do.... no has has provided a definitive answer. Thought this might work... $foo = inline_template("<%= [$pvdisks[ %>.length") but that gives meerr: Could not retrieve catalog from remote server: Error 400 on SERVER: compile error (erb):1: unknown regexp options - vdb (erb):1: syntax error, unexpected tINTEGER, expecting '']'' ...; _erbout.concat(( [/dev/xvdb1/dev/xvdc1] ).to_s); _erbout.c... ^ (erb):1: syntax error, unexpected '']'', expecting '')'' ...oncat(( [/dev/xvdb1/dev/xvdc1] ).to_s); _erbout.concat ".len... Yucko. -- 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.
On Wed, Aug 15, 2012 at 2:58 PM, Douglas Garstang <doug.garstang@gmail.com> wrote:> On Wed, Aug 15, 2012 at 2:55 PM, Ryan Coleman <ryan@puppetlabs.com> wrote: >> On Wed, Aug 15, 2012 at 2:51 PM, Douglas Garstang >> <doug.garstang@gmail.com> wrote: >>> How do I get get length of an array in puppet DSL? >> >> Hi Doug, >> >> You can install the puppetlabs-stdlib module from the Forge and use >> the size function. >> > > Ryan, > > No thanks. I''ve stopped using 3rd party modules. Providers don''t work > with environments... at least I don''t think they do.... no has has > provided a definitive answer. > > Thought this might work... > > $foo = inline_template("<%= [$pvdisks[ %>.length") > > but that gives meerr: Could not retrieve catalog from remote server: > Error 400 on SERVER: compile error > (erb):1: unknown regexp options - vdb > (erb):1: syntax error, unexpected tINTEGER, expecting '']'' > ...; _erbout.concat(( [/dev/xvdb1/dev/xvdc1] ).to_s); _erbout.c... > ^ > (erb):1: syntax error, unexpected '']'', expecting '')'' > ...oncat(( [/dev/xvdb1/dev/xvdc1] ).to_s); _erbout.concat ".len... > > Yucko.Oops.Typo in paste.I actually used $foo = inline_template("<%= [$pvdisks] %>.length") Doug. -- 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.
On 15 Aug 2012, at 23:58, Douglas Garstang wrote:> On Wed, Aug 15, 2012 at 2:55 PM, Ryan Coleman <ryan@puppetlabs.com> wrote: >> On Wed, Aug 15, 2012 at 2:51 PM, Douglas Garstang >> <doug.garstang@gmail.com> wrote: >>> How do I get get length of an array in puppet DSL? >> >> Hi Doug, >> >> You can install the puppetlabs-stdlib module from the Forge and use >> the size function. >> > > Ryan, > > No thanks. I''ve stopped using 3rd party modules. Providers don''t work > with environments... at least I don''t think they do.... no has has > provided a definitive answer.Could you elaborate on this one? I''m using the stdlib with environments. Never ran into any issues with that.> Thought this might work... > > $foo = inline_template("<%= [$pvdisks[ %>.length") > > but that gives meerr: Could not retrieve catalog from remote server: > Error 400 on SERVER: compile error > (erb):1: unknown regexp options - vdb > (erb):1: syntax error, unexpected tINTEGER, expecting '']'' > ...; _erbout.concat(( [/dev/xvdb1/dev/xvdc1] ).to_s); _erbout.c... > ^ > (erb):1: syntax error, unexpected '']'', expecting '')'' > ...oncat(( [/dev/xvdb1/dev/xvdc1] ).to_s); _erbout.concat ".len... > > Yucko. > > -- > 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. >Regards, Tom De Vylder -- 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.
On Wed, Aug 15, 2012 at 3:05 PM, Tom De Vylder <tom@penumbra.be> wrote:> > On 15 Aug 2012, at 23:58, Douglas Garstang wrote: > >> On Wed, Aug 15, 2012 at 2:55 PM, Ryan Coleman <ryan@puppetlabs.com> wrote: >>> On Wed, Aug 15, 2012 at 2:51 PM, Douglas Garstang >>> <doug.garstang@gmail.com> wrote: >>>> How do I get get length of an array in puppet DSL? >>> >>> Hi Doug, >>> >>> You can install the puppetlabs-stdlib module from the Forge and use >>> the size function. >>> >> >> Ryan, >> >> No thanks. I''ve stopped using 3rd party modules. Providers don''t work >> with environments... at least I don''t think they do.... no has has >> provided a definitive answer. > > Could you elaborate on this one? > I''m using the stdlib with environments. Never ran into any issues with that.Ryan, What version of puppet are you using? We''re on 2.7.1. Doug. -- 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.
On 16 Aug 2012, at 00:07, Douglas Garstang wrote:> On Wed, Aug 15, 2012 at 3:05 PM, Tom De Vylder <tom@penumbra.be> wrote: >> >> On 15 Aug 2012, at 23:58, Douglas Garstang wrote: >> >>> On Wed, Aug 15, 2012 at 2:55 PM, Ryan Coleman <ryan@puppetlabs.com> wrote: >>>> On Wed, Aug 15, 2012 at 2:51 PM, Douglas Garstang >>>> <doug.garstang@gmail.com> wrote: >>>>> How do I get get length of an array in puppet DSL? >>>> >>>> Hi Doug, >>>> >>>> You can install the puppetlabs-stdlib module from the Forge and use >>>> the size function. >>>> >>> >>> Ryan, >>> >>> No thanks. I''ve stopped using 3rd party modules. Providers don''t work >>> with environments... at least I don''t think they do.... no has has >>> provided a definitive answer. >> >> Could you elaborate on this one? >> I''m using the stdlib with environments. Never ran into any issues with that. > > Ryan, > > What version of puppet are you using? We''re on 2.7.1. > > Doug.Assuming you meant me… I''ve used environments early 2.6.x up till 2.7.18. The stdlib was used throughout the entire process without any hiccups, 2.7.1 is fairly old code. You might want to consider upgrading. Judging by the version number I guess you are using Debian. The version in backports is very stable. Or you could use the Puppetlabs repo of course. Tom -- 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.
On Wed, 2012-08-15 at 14:59 -0700, Douglas Garstang wrote:> On Wed, Aug 15, 2012 at 2:58 PM, Douglas Garstang > Oops.Typo in paste.I actually used > > $foo = inline_template("<%= [$pvdisks] %>.length")You seem to be misunderstanding how erb templates work; I strongly recommend that you go and re-read the docs. The syntax to use would look like this: $foo = inline_template("<%= @pvdisks.length %>") if the variable is local (in the same class/define), or $foo = inline_template("<%= scope.lookupvar(''scope::varname'').length %>") if it''s from somewhere else. Remember: everything between <% and %> in the template is interpreted as ruby code. Everything outside is passed through as text to the output. -- Calvin Walton <calvin.walton@kepstin.ca> -- 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.
On Wed, Aug 15, 2012 at 5:03 PM, Calvin Walton <calvin.walton@kepstin.ca> wrote:> On Wed, 2012-08-15 at 14:59 -0700, Douglas Garstang wrote: >> On Wed, Aug 15, 2012 at 2:58 PM, Douglas Garstang >> Oops.Typo in paste.I actually used >> >> $foo = inline_template("<%= [$pvdisks] %>.length") > > You seem to be misunderstanding how erb templates work; I strongly > recommend that you go and re-read the docs. The syntax to use would look > like this: > $foo = inline_template("<%= @pvdisks.length %>") > if the variable is local (in the same class/define), or > $foo = inline_template("<%= scope.lookupvar(''scope::varname'').length %>") > if it''s from somewhere else.The ''@'' character does not appear anywhere on the page http://docs.puppetlabs.com/guides/templating.html. Doug. -- 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.
On Wednesday, August 15, 2012, Douglas Garstang wrote:> On Wed, Aug 15, 2012 at 5:03 PM, Calvin Walton <calvin.walton@kepstin.ca<javascript:;>> > wrote: > > On Wed, 2012-08-15 at 14:59 -0700, Douglas Garstang wrote: > >> On Wed, Aug 15, 2012 at 2:58 PM, Douglas Garstang > >> Oops.Typo in paste.I actually used > >> > >> $foo = inline_template("<%= [$pvdisks] %>.length") > > > > You seem to be misunderstanding how erb templates work; I strongly > > recommend that you go and re-read the docs. The syntax to use would look > > like this: > > $foo = inline_template("<%= @pvdisks.length %>") > > if the variable is local (in the same class/define), or > > $foo = inline_template("<%= scope.lookupvar(''scope::varname'').length > %>") > > if it''s from somewhere else. > > The ''@'' character does not appear anywhere on the page > http://docs.puppetlabs.com/guides/templating.html.In fact, it does: http://docs.puppetlabs.com/guides/templating.html#referencing-variables> > Doug. > > -- > 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<javascript:;> > . > To unsubscribe from this group, send email to > puppet-users+unsubscribe@googlegroups.com <javascript:;>. > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. > >-- Ryan Coleman | about.me/ryc Modules & Forge @ Puppet Labs -- 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.