On 12/13/2010 03:01 AM, Alex wrote: > Hi, > > I want to create a single configuration file with one or two > differences, many times. Therefore, i'd like to do the following in > pseudo-code: > > files = [(a,b), (c,d), (e,f)...] > foreach a,b in files: > create_file(a,b) > > Which can then use what I think is a valid definition: > define create_file($port, $fullserver) { > file { "test.erb": > content => template('test.erb'), > } > }
Define doesn't define a function, it defines a resource type. You need no array, just use your define as: create_file { "/etc/foo1.conf": port => $a, fullserver => $b; "/etc/foo2.conf": port => $c, fullserver => $d; ... } You will want to change the define as follows: define create_file($port, $fullserver) { file { "$name": content => template('test.erb'), } } file { "$name": ... } instead of a static name. Otherwise puppet *will* complain about multiple definition of File["test.erb"]. HTH, 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-us...@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.