Puppet Class: filebeats::config

Defined in:
manifests/config.pp

Overview

Parameters:

  • elasticsearch_hosts (Array)
  • elasticsearch_index (String)
  • elasticsearch_password (String)
  • elasticsearch_protocol (String)
  • elasticsearch_ssl_certificate (String)
  • elasticsearch_ssl_certificate_authorities (Array)
  • elasticsearch_ssl_certificate_key (String)
  • elasticsearch_template_enabled (Boolean)
  • elasticsearch_template_name (String)
  • elasticsearch_template_overwrite (Boolean)
  • elasticsearch_template_path (String)
  • elasticsearch_username (String)
  • export_log_paths (Array)
  • kibana_url (String)
  • log_settings (Hash)
  • logstash_hosts (Array)
  • logstash_bulk_max_size (Integer)
  • logstash_index (String)
  • logstash_loadbalance (Boolean)
  • logstash_worker (Integer)
  • logstash_ssl_certificate (String)
  • logstash_ssl_certificate_authorities (Array)
  • logstash_ssl_certificate_key (String)
  • logstash_ttl (String)
  • modules (Hash)
  • modules_conf_dir (String)
  • inputs (Array)


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
# File 'manifests/config.pp', line 8

class filebeats::config (
  Array   $elasticsearch_hosts,
  String  $elasticsearch_index,
  String  $elasticsearch_password,
  String  $elasticsearch_protocol,
  String  $elasticsearch_ssl_certificate,
  Array   $elasticsearch_ssl_certificate_authorities,
  String  $elasticsearch_ssl_certificate_key,
  Boolean $elasticsearch_template_enabled,
  String  $elasticsearch_template_name,
  Boolean $elasticsearch_template_overwrite,
  String  $elasticsearch_template_path,
  String  $elasticsearch_username,
  Array   $export_log_paths,
  String  $kibana_url,
  Hash    $log_settings,
  Array   $logstash_hosts,
  Integer $logstash_bulk_max_size,
  String  $logstash_index,
  Boolean $logstash_loadbalance,
  Integer $logstash_worker,
  String  $logstash_ssl_certificate,
  Array   $logstash_ssl_certificate_authorities,
  String  $logstash_ssl_certificate_key,
  String  $logstash_ttl,
  Hash    $modules,
  String  $modules_conf_dir,
  Array   $inputs,
){
  $config_path = $filebeats::params::config_path

  if empty($log_settings) {
    $logging = {}
  } else {
    $logging = merge($::filebeats::params::log_settings, $log_settings)
  }

  if !empty($logstash_ttl) {
    if $logstash_ttl !~ /^\-?[0-9]+\.?[0-9]*(?:ns|us|ms|s|m|h)$/ {
      fail("Parameter \$logstash_ttl with content '${logstash_ttl}': is not a valid elastic duration")
    }
  }

  if empty($inputs) {
    validate_array($export_log_paths)

    $inputs_array =  [{'paths'         => $export_log_paths,
                            'input_type'    => 'log',
                            'doc_type' => 'log'
                          }]
  } else {
    $inputs_array = $inputs
  }

  file {"${config_path}/filebeat.yml":
    ensure  => present,
    owner   => root,
    group   => root,
    mode    => '0640',
    content => template('filebeats/filebeat.yml.erb'),
    require => Package['filebeat'],
    notify  => Service['filebeat'],
  }

#TODO turn this into a puppet resource
  $modules.each | String $action, Array $module_name | {
    $module_name.each | String $module| {
      if $action == 'enable' {
        exec { "filebeat_${module}_${action}":
          command => "filebeat modules ${action} ${module}",
          creates => "${modules_conf_dir}/${module}.yml",
          require => Package['filebeat'],
          notify  => Service['filebeat'],
        }
      } else {
        exec { "filebeat_${module}_${action}":
          command => "filebeat modules ${action} ${module}",
          creates => "${modules_conf_dir}/${module}.yml.disabled",
          require => Package['filebeat'],
          notify  => Service['filebeat'],
        }
      }
    }
  }

}