On 11/10/2010 05:16 PM, Gabriel Filion wrote: > On 11/10/2010 10:18 AM, luke.bigum wrote: >> Hi list, >> >> When declaring multiple resources at once with an array like this: >> >> file { [ "foo", "bar" ]: ... } >> >> Is there a way to access the current array element so as to pass this >> value as a parameter? So the "foo" resource has a parameter value >> "foo" and "bar" with a parameter value "bar"? > > > I think what you want is to use $name. it corresponds to the resource > name that is currently being worked on. > > file { [ "foo", "bar" ]: path => "/blah/${name}.txt", ... } >
Close, but no cigar. You need to wrap the file in a define like: define my_file() { file { "$name": owner => $name, mode => 640, } } Then you can just use $array = [ ... ] my_file { $array: } Regards, 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.