I'm looking for the syntax to copy an entire templates directory inside a puppet module. (Eg: templates/webconfig/file1.erb, templates/webconfig/config/file2.erb)
I tried to copy in below syntax:
file {"$http_home_dir/webconfig":
ensure => "directory",
owner => "$http_user",
group => "$http_group",
content => template("webconfig"),
recurse => true,
require => File["$http_home_dir"];
}
It doesn't worked. When i tried to use wildcard like below also, it didn't worked.
content => template("webconfig/*.erb"),
Is there anything specific I'm missing
Best Answer
You can only copy files wholesale using the
source
parameter, which copies files as-is. The only way you can copy multiple templates is to use multiplefile
resources.A way of shortening the amount of code you need is using a
define
resource type. For example, using Puppet 4 strict typing and the splat operator:Which can be used as:
Which will place a file at
$http_dir/webconfig/myfile
with the contents of templatewebconfig/myfile.erb
.You can also pass an array of file names, like so: