-
-
Notifications
You must be signed in to change notification settings - Fork 296
/
Copy pathconfigfile.pp
86 lines (82 loc) · 2.17 KB
/
configfile.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# This type represents a Logstash pipeline configuration file.
#
# Parameters are mutually exclusive. Only one should be specified.
#
# @param [String] content
# Literal content to be placed in the file.
#
# @param [String] template
# A template from which to render the file.
#
# @param [String] source
# A file resource to be used for the file.
#
# @param [String] path
# An optional full path at which to create the file.
#
# @example Create a config file content with literal content.
#
# logstash::configfile { 'heartbeat':
# content => 'input { heartbeat {} }',
# }
#
# @example Render a config file from a template.
#
# logstash::configfile { 'from-template':
# template => 'site-logstash-module/pipeline-config.erb',
# }
#
# @example Copy the config from a file source.
#
# logstash::configfile { 'apache':
# source => 'puppet://path/to/apache.conf',
# }
#
# @example Create a config at specific location. Good for multiple pipelines.
#
# logstash::configfile { 'heartbeat-2':
# content => 'input { heartbeat {} }',
# path => '/usr/local/etc/logstash/pipeline-2/heartbeat.conf'
# }
#
# @author https://github.com/elastic/puppet-logstash/graphs/contributors
#
define logstash::configfile(
$content = undef,
$source = undef,
$template = undef,
$path = undef,
)
{
include logstash
$owner = $logstash::logstash_user
$group = $logstash::logstash_group
$mode = '0640'
$require = Package['logstash'] # So that we have '/etc/logstash/conf.d'.
$tag = [ 'logstash_config' ] # So that we notify the service.
if($template) { $config = template($template) }
elsif($content) { $config = $content }
else { $config = undef }
if($path) { $config_file = $path }
else { $config_file = "${logstash::config_dir}/conf.d/${name}" }
if($config) {
file { $config_file:
content => $config,
owner => $owner,
group => $group,
mode => $mode,
require => $require,
tag => $tag,
}
}
elsif($source) {
file { $config_file:
source => $source,
owner => $owner,
group => $group,
mode => $mode,
require => $require,
tag => $tag,
}
}
}