Hi everyone, Is there a way to display correctly an array, each time I am trying to ''notice'' an array I have something like that: Here is the code: $array = [ ''test'' , ''test2''] notice("Here is the $array") The ouput is as follow: Here is the testtest2 There is no way to put a clean IFS for the ouput... -- 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.
Hi, [...]> There is no way to put a clean IFS for the ouput...You could use join() to join array elements with a single space and display then with notice, or have a define that would iterate over array elements for you printing them one by one. You can also try this little function: https://gist.github.com/1621778 I hope that helps. KW -- 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.
Thx this help a lot On Mon, Jan 16, 2012 at 6:04 PM, Krzysztof Wilczynski < krzysztof.wilczynski@linux.com> wrote:> Hi, > > [...] > > There is no way to put a clean IFS for the ouput... > > You could use join() to join array elements with a single space and > display then with notice, or have a define that would iterate over > array elements for you printing them one by one. > > You can also try this little function: https://gist.github.com/1621778 > > I hope that helps. > > KW > > -- > 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.
Hey me again, stupid question where do I put the file? On Tue, Jan 17, 2012 at 9:58 AM, Antidot SAS <antidotsas@gmail.com> wrote:> Thx this help a lot > > > On Mon, Jan 16, 2012 at 6:04 PM, Krzysztof Wilczynski < > krzysztof.wilczynski@linux.com> wrote: > >> Hi, >> >> [...] >> > There is no way to put a clean IFS for the ouput... >> >> You could use join() to join array elements with a single space and >> display then with notice, or have a define that would iterate over >> array elements for you printing them one by one. >> >> You can also try this little function: https://gist.github.com/1621778 >> >> I hope that helps. >> >> KW >> >> -- >> 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.
This is because puppet lacks the join() function, the obvious (but absent) partner to the split() function. However you can add it by using a custom function very easily, as we''ve done. Email me if you''d like a copy of the join.rb file to put in your puppet/parser/functions directory. The only caveat is to remember to type check arg[0] in case passed a string rather than an array. Steve Steve Shipway University of Auckland ITS UNIX Systems Design Lead s.shipway@auckland.ac.nz<mailto:s.shipway@auckland.ac.nz> Ph: +64 9 373 7599 ext 86487 ________________________________ From: puppet-users@googlegroups.com [puppet-users@googlegroups.com] on behalf of Antidot SAS [antidotsas@gmail.com] Sent: Tuesday, 17 January 2012 4:23 a.m. To: puppet-users Subject: [Puppet Users] Display correctly any array Hi everyone, Is there a way to display correctly an array, each time I am trying to ''notice'' an array I have something like that: Here is the code: $array = [ ''test'' , ''test2''] notice("Here is the $array") The ouput is as follow: Here is the testtest2 There is no way to put a clean IFS for the ouput... -- 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.
Hi Steve,> This is because puppet lacks the join() function, the obvious (but absent) partner to the split() function.[...] By default yes, it does. But you can mitigate this problem with puppetlabs-stdlib[1] and/or tackle this one: https://github.com/kwilczynski/puppet-functions/blob/master/lib/puppet/parser/functions/join.rb and probably this one might also come in handy: https://github.com/kwilczynski/puppet-functions/blob/master/lib/puppet/parser/functions/prefix.rb 1. https://github.com/puppetlabs/puppetlabs-stdlib KW -- 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 01/16/2012 04:23 PM, Antidot SAS wrote:> Hi everyone, > > > Is there a way to display correctly an array, each time I am trying to > ''notice'' an array I have something like that: > Here is the code: > $array = [ ''test'' , ''test2''] > > notice("Here is the $array") > > The ouput is as follow: > Here is the testtest2 > > > There is no way to put a clean IFS for the ouput...Seeing as this has not been mentioned in the thread yet, I''m compelled to add: $array_to_str = inline_template("<%= array * '', '' %>") or even notify { "my-notify": message => inline_template("Here is the <%= array * '', '' %>."); } Cheers, Felix -- 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.
Hi Felix,> Seeing as this has not been mentioned in the thread yet, I''m compelled > to add: > > $array_to_str = inline_template("<%= array * '', '' %>") > > or even > > notify { "my-notify": > message => inline_template("Here is the <%= array * '', '' %>."); > > }Ah, the oldie but goodie inline_template() abuse :-) We should stop endorsing this, really, hehe :) KW -- 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.
As long as we''re lacking a builtin method for pretty-printing data structures during a debug session inline templates are going to continue to be popular in scenarios like this. On Tue, Jan 17, 2012 at 10:06 AM, Krzysztof Wilczynski <krzysztof.wilczynski@linux.com> wrote:> Hi Felix, > >> Seeing as this has not been mentioned in the thread yet, I''m compelled >> to add: >> >> $array_to_str = inline_template("<%= array * '', '' %>") >> >> or even >> >> notify { "my-notify": >> message => inline_template("Here is the <%= array * '', '' %>."); >> >> } > > Ah, the oldie but goodie inline_template() abuse :-) > > We should stop endorsing this, really, hehe :) > > KW > > -- > 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.
Hi Aaron,> As long as we''re lacking a builtin method for pretty-printing data > structures during a debug session inline templates are going to > continue to be popular in scenarios like this.Sadly, you are right. I personally dislike inline_template() hackety hacks and would rather solve a problem by making a more appropriate newfunction etc :) For instance, I have this simple dump() of mine, but something like a built-in var_dump() (a''la PHP) would be handy, indeed :) P.S. I am about to move dump() from Gists to a proper place on my github. KW -- 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.
This (or something like it) should be a candidate for stdlib. On Tue, Jan 17, 2012 at 10:47 AM, Krzysztof Wilczynski <krzysztof.wilczynski@linux.com> wrote:> Hi Aaron, > >> As long as we''re lacking a builtin method for pretty-printing data >> structures during a debug session inline templates are going to >> continue to be popular in scenarios like this. > > Sadly, you are right. > > I personally dislike inline_template() hackety hacks and would rather > solve a problem by making a more appropriate newfunction etc :) > > For instance, I have this simple dump() of mine, but something like a > built-in var_dump() (a''la PHP) would be handy, indeed :) > > P.S. I am about to move dump() from Gists to a proper place on my > github. > > KW > > -- > 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.