Hi. I have the following array in the hiera: files: - a - b - c and I want to create files: file_a file_b file_c from template "file". Is there a clean way to do it because as far as i know puppet DL doesn''t support loops... -- Jakov Sosic www.srce.unizg.hr -- 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.
Change your yaml file to: files: - a - b - c Then puppet will read it in as an array. Pass the array to a define and the define will run once for each element of the array Steven > Date: Sat, 17 Nov 2012 03:27:20 +0100> From: jsosic@srce.hr > To: puppet-users@googlegroups.com > Subject: [Puppet Users] Creating files from array? > > Hi. > > I have the following array in the hiera: > > files: - a > - b > - c > > and I want to create files: > > file_a > file_b > file_c > > from template "file". > > > Is there a clean way to do it because as far as i know puppet DL doesn''t > support loops... > > > -- > Jakov Sosic > www.srce.unizg.hr > > -- > 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 11/17/2012 03:51 AM, Steven Nemetz wrote:> Change your yaml file to: > > files: > - a > - b > - cYou can write it like this too: files: - a - b ... No need for that specific newline. I don''t know if it''s correct but it works.> Then puppet will read it in as an array. Pass the array to a define and > the define will run once for each element of the arrayThank you, that worked. Here is the example without using hiera, just the for benefit of future readers: define class::mydefine ( $file=$title, ) { file {"/tmp/$file": ensure => file, owner => root, group => root, mode => ''0644'', content => template(''class/some.erb''), } } files = [''a'',''b'',''c''] class::mydefine{$files: } -- Jakov Sosic www.srce.unizg.hr -- 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.