This is *the* classic case for a defined type.
define my_templated_file() {
$directory = "/home/malintha/adikari5"
file { "$directory/$name/":
ensure => present,
owner => 'root',
group => 'root',
mode => '0777',
content => template("config/${name}.erb"),
}
Then just
my_templated_file { $filenames: }
Note that I fixed the duplicate ".xml" in the template name for you.
HTH,
Felix
On 06/24/2014 12:31 PM, Malintha Adikari wrote:
> $filenames=['carbon.xml','loadbalancer.conf','master-datasources.xml']
>
> I want to call template for each file name in the array. There are tree
> file names in my array and I want to call below code for each file name
>
> file { '${filename}':
> path => "/home/malintha/adikari5/${filenames}",
> ensure => present,
> owner => 'root',
> group => 'root',
> mode => '0777',
> content => template("config/${filenames}.xml.erb"),
> }
>
> How this can be done ?
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/53A9547E.5000307%40alumni.tu-berlin.de.
For more options, visit https://groups.google.com/d/optout.