Puppet Class: r_profile::file
- Defined in:
- manifests/file.pp
Overview
R_profile::File
Support for managing files and directories
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'manifests/file.pp', line 8
class r_profile::file(
$files = hiera("r_profile::file::files", false),
$directories = hiera("r_profile::file::directories", false),
$process_template = hiera("r_profile::file::process_template", false),
) {
$default_directory = { "ensure" => "directory"}
$default_file = { "ensure" => "file"}
if $files {
$files.each |$title, $opts| {
if $process_template {
if dig($opts, 'content') and $opts['content'] =~ /^template(.+)$/ {
# process the template and return the content
$template = regsubst($opts["content"], '^template\(([^)]+)\)$', '\1')
$temp = {
"content" => template($template)
}
# merge the hashes, allowing parsed content to override
$_opts = merge($opts, $temp)
}
} else {
$_opts = $opts
}
file {
default:
* => $default_file,
;
$title:
* => $_opts,
}
}
}
if $directories {
create_resources("file", $directories, $default_directory)
}
}
|