Hello, I am trying to create a new array by combining two other arrays. I get the following error while running : Duplicate definition: Print[test0] is already defined in file /etc/puppet/manifests/test.pp at line 47; cannot redefine at /etc/puppet/manifests/test.pp:47 My code is similar to this : <snip> ..... ..... $sys_server = [ ginger , test0 ] $usr_server = [ test0, test1, test2 ] $server = split(inline_template("<%= (sys_server+usr_server).join('','') %>"),'','') ..... ..... </snip> This way clearly not working. Is there a tweak somewhere to remove the duplicates while joining the arrays ? or is there any other way to join two arrays to create another one ? Thanks very much. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/RpAo82K-QiMJ. 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 22, 2012 at 6:56 AM, iamauser <tapas.sarangi@gmail.com> wrote:> Hello, > > I am trying to create a new array by combining two other arrays. I get the > following error while running : > > Duplicate definition: Print[test0] is already defined in file > /etc/puppet/manifests/test.pp at line 47; cannot redefine at > /etc/puppet/manifests/test.pp:47 > > My code is similar to this : > <snip> > ..... > ..... > $sys_server = [ ginger , test0 ] > $usr_server = [ test0, test1, test2 ] > > $server = split(inline_template("<%= (sys_server+usr_server).join('','') > %>"),'','') > ..... > ..... > </snip> > > This way clearly not working. Is there a tweak somewhere to remove the > duplicates while joining the arrays ? or is there any other way to join two > arrays to create another one ?Use the unique and join function from stdlib. Nan -- 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.
Any example, for this case ? I didn''t find any on the web... thanks Use the unique and join function from stdlib.> > Nan >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/104tOgE4b9wJ. 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 22, 2012 at 10:29 AM, iamauser <tapas.sarangi@gmail.com> wrote:> Any example, for this case ? I didn''t find any on the web... > > thanksBleh, join is string only. unique will remove any duplicates: $sys_server = [ ginger , test0 ] $usr_server = [ test0, test1, test2 ] $all = [$sys_server, $usr_server] $server = unique(flatten($all)) notify { $server: } Nan -- 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.
Nick Fagerlund
2012-Aug-22 17:43 UTC
Re: [Puppet Users] Duplicate definition : Merging arrays
You can see inline docs for every stdlib function by reading the code: https://github.com/puppetlabs/puppetlabs-stdlib/tree/master/lib/puppet/parser/functions Install the module with: $ sudo puppet module install puppetlabs-stdlib And probably use unique and flatten to do what you''re trying to do. Like this. $server = unique( flatten( [$sys_server, $usr_server] ) ) On Wednesday, August 22, 2012 10:29:27 AM UTC-7, iamauser wrote:> > Any example, for this case ? I didn''t find any on the web... > > thanks > > > Use the unique and join function from stdlib. >> >> Nan >> >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/8wnGyx85eiIJ. 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.
Nick Fagerlund
2012-Aug-22 17:44 UTC
Re: [Puppet Users] Duplicate definition : Merging arrays
Whoops, collision! Reassuring that we both did the same thing though. :) -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/IsnRDusKXDoJ. 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.
Thanks very much to both of you. Very helpful. -Tapas On Wednesday, August 22, 2012 7:44:25 PM UTC+2, Nick Fagerlund wrote:> > Whoops, collision! Reassuring that we both did the same thing though. :) >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/uSLj0nc2fREJ. 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.
Maybe Matching Threads
- Nodes Could not retrieve catalog from remote server: execution expired
- Running ENC alongside site.pp (node defn)
- custom define type for array with 'case' argument pass to it
- Bug#784810: Bug#784810: Xen domU try ton access to dom0 LVM Volume group
- using RBD with libvirt 0.9.13