|
183 | 183 | $collect_ec2_tags = false, |
184 | 184 | $collect_instance_metadata = true, |
185 | 185 | $tags = [], |
| 186 | + $integrations = {}, |
| 187 | + $hiera_integrations = false, |
186 | 188 | $hiera_tags = false, |
187 | 189 | $facts_to_tags = [], |
188 | 190 | $puppet_run_reports = false, |
|
239 | 241 | $sd_jmx_enable = false, |
240 | 242 | $consul_token = '', |
241 | 243 | $conf_dir = $datadog_agent::params::conf_dir, |
| 244 | + $conf_dir_purge = $datadog_agent::params::conf_dir_purge, |
242 | 245 | $service_name = $datadog_agent::params::service_name, |
243 | 246 | $package_name = $datadog_agent::params::package_name, |
244 | 247 | $dd_user = $datadog_agent::params::dd_user, |
|
249 | 252 |
|
250 | 253 | # Allow ports to be passed as integers or strings. |
251 | 254 | # lint:ignore:only_variable_string |
| 255 | + $_dogstatsd_port = "${dogstatsd_port}" |
252 | 256 | $_statsd_forward_port = "${statsd_forward_port}" |
253 | 257 | $_proxy_port = "${proxy_port}" |
254 | 258 | $_graphite_listen_port = "${graphite_listen_port}" |
|
271 | 275 | validate_bool($log_to_syslog) |
272 | 276 | validate_bool($manage_repo) |
273 | 277 | validate_string($log_level) |
274 | | - validate_integer($dogstatsd_port) |
| 278 | + validate_re($_dogstatsd_port, '^\d*$') |
275 | 279 | validate_string($statsd_histogram_percentiles) |
276 | 280 | validate_re($_statsd_forward_port, '^\d*$') |
277 | 281 | validate_string($proxy_host) |
|
324 | 328 | $local_tags = $tags |
325 | 329 | } |
326 | 330 |
|
| 331 | + if $hiera_integrations { |
| 332 | + $local_integrations = hiera_hash('datadog_agent::integrations') |
| 333 | + } else { |
| 334 | + $local_integrations = $integrations |
| 335 | + } |
| 336 | + |
| 337 | + datadog_agent::tag{$local_tags: } |
| 338 | + datadog_agent::tag{$facts_to_tags: |
| 339 | + lookup_fact => true, |
| 340 | + } |
| 341 | + |
327 | 342 | include datadog_agent::params |
328 | 343 | case upcase($log_level) { |
329 | 344 | 'CRITICAL': { $_loglevel = 'CRITICAL' } |
|
354 | 369 | require => Package['datadog-agent'], |
355 | 370 | } |
356 | 371 |
|
357 | | - # main agent config file |
358 | | - # content |
359 | | - if ($extra_template != '') { |
360 | | - $agent_conf_content = template( |
361 | | - 'datadog_agent/datadog.conf.erb', |
362 | | - $extra_template |
363 | | - ) |
364 | | - } else { |
365 | | - $agent_conf_content = template('datadog_agent/datadog.conf.erb') |
| 372 | + file { $conf_dir: |
| 373 | + ensure => directory, |
| 374 | + purge => $conf_dir_purge, |
| 375 | + recurse => true, |
| 376 | + force => $conf_dir_purge, |
| 377 | + owner => $dd_user, |
| 378 | + group => $dd_group, |
| 379 | + notify => Service['datadog-agent'] |
366 | 380 | } |
367 | | - file { '/etc/dd-agent/datadog.conf': |
368 | | - ensure => file, |
369 | | - content => $agent_conf_content, |
| 381 | + |
| 382 | + concat {'/etc/dd-agent/datadog.conf': |
370 | 383 | owner => $datadog_agent::params::dd_user, |
371 | 384 | group => $datadog_agent::params::dd_group, |
372 | 385 | mode => '0640', |
373 | 386 | notify => Service[$datadog_agent::params::service_name], |
374 | 387 | require => File['/etc/dd-agent'], |
375 | 388 | } |
376 | 389 |
|
| 390 | + concat::fragment{ 'datadog header': |
| 391 | + target => '/etc/dd-agent/datadog.conf', |
| 392 | + content => template('datadog_agent/datadog_header.conf.erb'), |
| 393 | + order => '01', |
| 394 | + } |
| 395 | + |
| 396 | + concat::fragment{ 'datadog tags': |
| 397 | + target => '/etc/dd-agent/datadog.conf', |
| 398 | + content => 'tags: ', |
| 399 | + order => '02', |
| 400 | + } |
| 401 | + |
| 402 | + concat::fragment{ 'datadog footer': |
| 403 | + target => '/etc/dd-agent/datadog.conf', |
| 404 | + content => template('datadog_agent/datadog_footer.conf.erb'), |
| 405 | + order => '05', |
| 406 | + } |
| 407 | + |
| 408 | + concat::fragment{ 'datadog apm footer': |
| 409 | + target => '/etc/dd-agent/datadog.conf', |
| 410 | + content => template('datadog_agent/datadog_apm_footer.conf.erb'), |
| 411 | + order => '06', |
| 412 | + } |
| 413 | + |
| 414 | + |
377 | 415 | if $puppet_run_reports { |
378 | 416 | class { 'datadog_agent::reports': |
379 | 417 | api_key => $api_key, |
|
383 | 421 | hostname_extraction_regex => $hostname_extraction_regex, |
384 | 422 | } |
385 | 423 | } |
| 424 | + |
| 425 | + create_resources('datadog_agent::integration', $local_integrations) |
386 | 426 | } |
0 commit comments