# Is it possible to specify a source for an array of files

I would like to manage the attributes for an array of files but cannot figure out how to set the source. What I have tried so far bombs with the error:

Parameter source failed on File[/foo1]: Could not understand source puppet:///modules/foo/[foo1, foo2, foo3, foo4]: bad URI (is not URI?):puppet:///modules/foo/[/etc/foo1,%20/etc/foo2,%20/etc/foo3,%20/etc/oo4,%20/..........


class foo::config {

$files_for_foo = [ '/etc/foo1', '/etc/foo2', '/etc/foo3', '/etc/foo4'] file {$files_for_foo
ensure  => file,
source  => "puppet:///modules/foo/${files_for_foo}", owner => 'root', group => 'root', mode => '0644'; } }  I was hoping to not have to manage each of these files individually. Thanks for any guidance. edit retag close merge delete ## 1 Answer Sort by » oldest newest most voted Is this what you mean? class foo::config {$files = {
'/etc/foo1' => { source => 'puppet:///modules/foo/foo1' },
'/etc/foo2' => { source => 'puppet:///modules/foo/foo2' },
'/etc/foo3' => { source => 'puppet:///modules/foo/foo3' },
'/etc/foo4' => { source => 'puppet:///modules/foo/foo4' },
}
create_resources(file, \$files, {
owner => 'root',
group => 'root',
mode  => '0644',
})
}

more

This works well. Thanks for your help!

( 2016-04-13 13:31:04 -0500 )edit