forked from DanielRedOak/puppet-logstashforwarder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfile.pp
42 lines (38 loc) · 1.17 KB
/
file.pp
1
2
3
4
5
6
7
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
define lumberjack::file (
$paths,
$fields,
){
File {
owner => 'root',
group => 'root',
}
if ($paths != '') {
validate_array($paths)
}
# Let's have the option of using an array OR a hash. Arrays are nice
# because they shouldn't be randomly re-ordered.
# requies stdlib
# The validate step may or may not be silly depending on if it's more
# comprehensive than the is_hash/is_array functions.
if is_hash($fields) {
validate_hash($fields)
$fields_to_template = $fields
}
elsif is_array($fields) {
validate_array($fields)
# Here we convert the array to a hash. Puppet doesn't SEEM to
# munge hashes when it passes them to templates... maybe.
# Note that sub-arrays are not supported.
$fields_to_template = hash($fields)
}
else {
fail('fields must be either an array or a hash!')
}
if ($lumberjack::ensure == 'present' ) {
concat::fragment{"${name}":
target => "${lumberjack::configdir}/${lumberjack::config}",
content => template("${module_name}/file_format.erb"),
order => 010,
}
}
}