-
Notifications
You must be signed in to change notification settings - Fork 259
Expand file tree
/
Copy pathinit.pp
More file actions
351 lines (344 loc) · 11.6 KB
/
init.pp
File metadata and controls
351 lines (344 loc) · 11.6 KB
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
# Class: datadog_agent
#
# This class contains the agent installation mechanism for the Datadog module
#
# Parameters:
# $dd_url:
# The host of the Datadog intake server to send agent data to.
# Defaults to https://app.datadoghq.com.
# $host:
# $api_key:
# Your DataDog API Key. Please replace with your key value.
# $collect_ec2_tags
# Collect AWS EC2 custom tags as agent tags.
# $collect_instance_metadata
# The Agent will try to collect instance metadata for EC2 and GCE instances.
# $tags
# Optional array of tags.
# $hiera_tags
# Boolean to grab tags from hiera to allow merging
# $facts_to_tags
# Optional array of facts' names that you can use to define tags following
# the scheme: "fact_name:fact_value".
# $puppet_run_reports
# Will send results from your puppet agent runs back to the datadog service.
# $puppetmaster_user
# Will chown the api key used by the report processor to this user.
# $non_local_traffic
# Enable you to use the agent as a proxy. Defaults to false.
# See https://github.com/DataDog/dd-agent/wiki/Proxy-Configuration
# $dogstreams
# Optional array of logs to parse and custom parsers to use.
# See https://github.com/DataDog/dd-agent/blob/ed5e698/datadog.conf.example#L149-L178
# $log_level
# Set value of 'log_level' variable. Default is 'info' as in dd-agent.
# Valid values here are: critical, debug, error, fatal, info, warn and warning.
# $hostname_extraction_regex
# Completely optional.
# Instead of reporting the puppet nodename, use this regex to extract the named
# 'hostname' captured group to report the run in Datadog.
# ex.: '^(?<hostname>.*\.datadoghq\.com)(\.i-\w{8}\..*)?$'
# $log_to_syslog
# Set value of 'log_to_syslog' variable. Default is true -> yes as in dd-agent.
# Valid values here are: true or false.
# $dogstatsd_port
# Set value of the 'dogstatsd_port' variable. Defaultis 8125.
# $statsd_forward_host
# Set the value of the statsd_forward_host varable. Used to forward all
# statsd metrics to another host.
# $statsd_forward_port
# Set the value of the statsd_forward_port varable. Used to forward all
# statsd metrics to another host.
# $manage_repo
# Boolean to indicate whether this module should attempt to manage
# the package repo. Default true.
# $proxy_host
# Set value of 'proxy_host' variable. Default is blank.
# $proxy_port
# Set value of 'proxy_port' variable. Default is blank.
# $proxy_user
# Set value of 'proxy_user' variable. Default is blank.
# $proxy_password
# Set value of 'proxy_password' variable. Default is blank.
# $graphite_listen_port
# Set graphite listener port
# $extra_template
# Optional, append this extra template file at the end of
# the default datadog.conf template
# $skip_apt_key_trusting
# Skip trusting the apt key. Default is false. Useful if you have a
# separate way of adding keys.
# $skip_ssl_validation
# Skip SSL validation.
# $use_curl_http_client
# Uses the curl HTTP client for the forwarder
# $collect_ec2_tas
# Presents custom EC2 tags as agent tags to datadog
# Boolean. Default: False
# $collect_instance_metadata
# Enables the agent to try and gather instance metadata on EC2/GCE
# Boolean. Default: true
# $recent_point_threshold
# Sets the threshold for accepting points.
# String. Default: empty (30 second intervals)
# $listen_port
# Change the port that the agent listens on
# String. Default: empty (port 17123 in dd-agent)
# $additional_checksd
# Additional directory to look for datadog checks in
# String. Default: empty
# $bind_host
# The loopback address the forwarder and Dogstatsd will bind.
# String. Default: empty
# $use_pup
# Enables the local pup dashboard
# Boolean. Default: false
# $pup_port
# Specifies the port to be used by pup. Must have use_pup set
# String. Default: empty
# $pup_interface
# Specifies which interface pup will use. Must have use_pup set
# String. Default: empty
# $pup_url
# Specifies the URL used to access pup. Must have use_pup set
# String. Default: empty
# $use_dogstatsd
# Enables the dogstatsd server
# Boolean. Default: true
# $dogstatsd_port
# Specifies the port to be used by dogstatsd. Must have use_dogstatsd set
# String. Default: empty
# $dogstatsd_target
# Change the target to be used by dogstatsd. Must have use_dogstatsd set
# set
# String. Default: empty
# $dogstatsd_interval
# Change the dogstatsd flush period. Must have use_dogstatsd set
# String. Default: empty ( 10 second interval)
# $dogstatsd_normalize
# Enables 1 second nomralization. Must have use_dogstatsd set
# Boolean. Default: true
# $statsd_forward_host
# Enables forwarding of statsd packetsto host. Must have use_dogstatsd set
# String. Default: empty
# $statsd_forward_port
# Specifis port for $statsd_forward_host. Must have use_dogstatsd set
# String. Default: empty
# $device_blacklist_re
# Specifies pattern for device blacklisting.
# String. Default: empty
# $ganglia_host
# Specifies host where gmetad is running
# String. Default: empty
# $ganglia_port
# Specifies port for $ganglia_host
# String. Default: empty
# $dogstreams
# Specifies port for list of logstreams/modules to be used.
# String. Default: empty
# $custom_emitters
# Specifies a comma seperated list of non standard emitters to be used
# String. Default: empty
# $custom_emitters
# Specifies a comma seperated list of non standard emitters to be used
# String. Default: empty
# $collector_log_file
# Specifies the log file location for the collector system
# String. Default: empty
# $forwarder_log_file
# Specifies the log file location for the forwarder system
# String. Default: empty
# $dogstatsd
# Specifies the log file location for the dogstatsd system
# String. Default: empty
# $pup_log_file
# Specifies the log file location for the pup system
# String. Default: empty
#
#
# Actions:
#
# Requires:
#
# Sample Usage:
#
# include datadog_agent
#
# OR
#
# class { 'datadog_agent':
# api_key => 'your key',
# tags => ['env:production', 'linux'],
# puppet_run_reports => false,
# puppetmaster_user => puppet,
# }
#
#
class datadog_agent(
$dd_url = 'https://app.datadoghq.com',
$host = '',
$api_key = 'your_API_key',
$collect_ec2_tags = false,
$collect_instance_metadata = true,
$tags = [],
$hiera_tags = false,
$facts_to_tags = [],
$puppet_run_reports = false,
$puppet_gem_provider = 'puppetserver_gem',
$puppetmaster_user = 'puppet',
$non_local_traffic = false,
$dogstreams = [],
$log_level = 'info',
$log_to_syslog = true,
$service_ensure = 'running',
$service_enable = true,
$manage_repo = true,
$hostname_extraction_regex = nil,
$dogstatsd_port = 8125,
$statsd_forward_host = '',
$statsd_forward_port = '',
$statsd_histogram_percentiles = '0.95',
$proxy_host = '',
$proxy_port = '',
$proxy_user = '',
$proxy_password = '',
$graphite_listen_port = '',
$extra_template = '',
$ganglia_host = '',
$ganglia_port = 8651,
$skip_ssl_validation = false,
$skip_apt_key_trusting = false,
$use_curl_http_client = false,
$recent_point_threshold = '',
$listen_port = '',
$additional_checksd = '',
$bind_host = '',
$use_pup = false,
$pup_port = '',
$pup_interface = '',
$pup_url = '',
$use_dogstatsd = true,
$dogstatsd_target = '',
$dogstatsd_interval = '',
$dogstatsd_normalize = true,
$device_blacklist_re = '',
$custom_emitters = '',
$collector_log_file = '',
$forwarder_log_file = '',
$dogstatsd_log_file = '',
$pup_log_file = '',
$syslog_host = '',
$syslog_port = '',
) inherits datadog_agent::params {
validate_string($dd_url)
validate_string($host)
validate_string($api_key)
validate_array($tags)
validate_bool($hiera_tags)
validate_array($dogstreams)
validate_array($facts_to_tags)
validate_bool($puppet_run_reports)
validate_string($puppet_gem_provider)
validate_string($puppetmaster_user)
validate_bool($non_local_traffic)
validate_bool($log_to_syslog)
validate_bool($manage_repo)
validate_string($log_level)
validate_integer($dogstatsd_port)
validate_string($statsd_histogram_percentiles)
validate_string($statsd_forward_port)
validate_string($proxy_host)
validate_string($proxy_port)
validate_string($proxy_user)
validate_string($proxy_password)
validate_string($graphite_listen_port)
validate_string($extra_template)
validate_string($ganglia_host)
validate_integer($ganglia_port)
validate_bool($skip_ssl_validation)
validate_bool($skip_apt_key_trusting)
validate_bool($use_curl_http_client)
validate_bool($collect_ec2_tags)
validate_bool($collect_instance_metadata)
validate_string($recent_point_threshold)
validate_string($listen_port)
validate_string($additional_checksd)
validate_string($bind_host)
validate_bool($use_pup)
validate_string($pup_port)
validate_string($pup_interface)
validate_string($pup_url)
validate_bool($use_dogstatsd)
validate_string($dogstatsd_target)
validate_string($dogstatsd_interval)
validate_bool($dogstatsd_normalize)
validate_string($statsd_forward_host)
validate_string($device_blacklist_re)
validate_string($custom_emitters)
validate_string($collector_log_file)
validate_string($forwarder_log_file)
validate_string($dogstatsd_log_file)
validate_string($pup_log_file)
validate_string($syslog_host)
validate_string($syslog_port)
if $hiera_tags {
$local_tags = hiera_array('datadog_agent::tags')
} else {
$local_tags = $tags
}
include datadog_agent::params
case upcase($log_level) {
'CRITICAL': { $_loglevel = 'CRITICAL' }
'DEBUG': { $_loglevel = 'DEBUG' }
'ERROR': { $_loglevel = 'ERROR' }
'FATAL': { $_loglevel = 'FATAL' }
'INFO': { $_loglevel = 'INFO' }
'WARN': { $_loglevel = 'WARN' }
'WARNING': { $_loglevel = 'WARNING' }
default: { $_loglevel = 'INFO' }
}
case $::operatingsystem {
'Ubuntu','Debian' : { include datadog_agent::ubuntu }
'RedHat','CentOS','Fedora','Amazon','Scientific' : {
class { 'datadog_agent::redhat':
manage_repo => $manage_repo,
}
}
default: { fail("Class[datadog_agent]: Unsupported operatingsystem: ${::operatingsystem}") }
}
file { '/etc/dd-agent':
ensure => present,
owner => 'root',
group => 'root',
mode => '0755',
require => Package['datadog-agent'],
}
# main agent config file
# content
if ($extra_template != '') {
$agent_conf_content = template(
'datadog_agent/datadog.conf.erb',
$extra_template
)
} else {
$agent_conf_content = template('datadog_agent/datadog.conf.erb')
}
file { '/etc/dd-agent/datadog.conf':
ensure => file,
content => $agent_conf_content,
owner => $datadog_agent::params::dd_user,
group => $datadog_agent::params::dd_group,
mode => '0640',
notify => Service[$datadog_agent::params::service_name],
require => File['/etc/dd-agent'],
}
if $puppet_run_reports {
class { 'datadog_agent::reports':
api_key => $api_key,
puppet_gem_provider => $puppet_gem_provider,
puppetmaster_user => $puppetmaster_user,
dogapi_version => $datadog_agent::params::dogapi_version,
hostname_extraction_regex => $hostname_extraction_regex,
}
}
}