Puppet Class: splunk

Defined in:
manifests/init.pp

Overview

Class: splunk

Full description of class splunk here.

Parameters

Document parameters here.

Variables

Here you should define a list of variables that this module would require.

Examples

class { splunk: }

Authors

Christopher Caldwell <caldwell@gwu.edu>

Copyright 2017 Christopher Caldwell

Parameters:

  • version (String)
  • release (String)
  • type (String)
  • kernel_version (String)
  • adhoc_searchhead (Boolean)
  • autolb (Boolean)
  • autolbfrequency (Integer)
  • cacert (String)
  • captain_is_adhoc (Boolean)
  • ciphersuite (String)
  • cluster_mode (String)
  • confdir (String)
  • create_user (Boolean)
  • deployment_disable (Boolean)
  • deployment_interval (Integer)
  • dispatch_earliest (String)
  • dispatch_latest (String)
  • dispatch_size (Integer)
  • ecdhcurves (String)
  • email (String)
  • ext (String)
  • forcetimebasedautolb (Boolean)
  • install_path (String)
  • is_captain (Boolean)
  • license_master_mode (String)
  • mailserver (String)
  • managesecret (Boolean)
  • max_rawsize_perchunk (Integer)
  • max_searches (Integer)
  • preferred_captain (Boolean)
  • privkey (String)
  • scheduler_disable (Boolean)
  • search_maxinfocsv (Integer)
  • search_maxqueue (Integer)
  • server_site (String)
  • servercert (String)
  • servercertpass (String)
  • source (String)
  • group (String)
  • user (String)
  • replace_hash (Boolean)
  • splunknotcp_ssl (Boolean)
  • splunknotcp (Boolean)
  • sslclientcert (Boolean)
  • sslclientcompression (Boolean)
  • sslcompression (Boolean)
  • sslnegotiation (Boolean)
  • sslstsheader (Boolean)
  • sslv3 (Boolean)
  • sslverify (Boolean)
  • sslversions (String)
  • subsearch_maxout (Integer)
  • subsearch_maxtime (Integer)
  • subsearch_ttl (Integer)
  • symmkey (String)
  • tarcmd (String)
  • use_mounts (Boolean)
  • use_systemd (Boolean)
  • webcert (String)
  • webssl (Boolean)
  • signatureversion (Enum['v1,v2', 'v2'])
  • legacyciphers (Enum['decryptOnly', 'disabled'])
  • s3_encryption (Enum['sse-s3', 'sse-kms', 'sse-c', 'none'])
  • license_master (Optional[String])
  • cold_path (Optional[String])
  • warm_path (Optional[String])
  • datamodel_path (Optional[String])
  • maxwarm (Integer) (defaults to: 0)
  • maxcold (Integer) (defaults to: 0)
  • s3_keyrefresh (Integer) (defaults to: 86400)
  • acls (Optional[Hash]) (defaults to: undef)
  • admin_pass (Optional[String]) (defaults to: undef)
  • auth_pass (Optional[String]) (defaults to: undef)
  • authentication (Optional[String]) (defaults to: undef)
  • authconfig (Optional[Hash]) (defaults to: undef)
  • cert_source (Optional[String]) (defaults to: undef)
  • indexes (Optional[Hash]) (defaults to: undef)
  • inputs (Optional[Hash]) (defaults to: undef)
  • apps (Optional[Hash]) (defaults to: undef)
  • geo_source (Optional[String]) (defaults to: undef)
  • geo_hash (Optional[String]) (defaults to: undef)
  • clusters (Optional[Tuple]) (defaults to: undef)
  • deployment_server (Optional[String]) (defaults to: undef)
  • licenses (Optional[Tuple]) (defaults to: undef)
  • repl_count (Optional[Integer]) (defaults to: undef)
  • repl_port (Optional[Integer]) (defaults to: undef)
  • roles (Optional[Tuple]) (defaults to: undef)
  • search_deploy (Optional[String]) (defaults to: undef)
  • mailfrom (Optional[String]) (defaults to: undef)
  • serviceurl (Optional[String]) (defaults to: undef)
  • shcluster_label (Optional[String]) (defaults to: undef)
  • shcluster_mode (Optional[String]) (defaults to: undef)
  • shcluster_members (Optional[Array]) (defaults to: undef)
  • tcpout (Optional[Hash]) (defaults to: undef)
  • remote_path (Optional[String]) (defaults to: undef)
  • s3_access_key (Optional[String]) (defaults to: undef)
  • s3_secret_key (Optional[String]) (defaults to: undef)
  • s3_endpoint (Optional[String]) (defaults to: undef)
  • s3_sslverify (Optional[string]) (defaults to: undef)
  • s3_sslversions (Optional[string]) (defaults to: undef)
  • s3_ssl_altname (Optional[string]) (defaults to: undef)
  • s3_ssl_capath (Optional[string]) (defaults to: undef)
  • s3_ciphersuite (Optional[string]) (defaults to: undef)
  • s3_ecdhcurves (Optional[string]) (defaults to: undef)
  • s3_region (Optional[string]) (defaults to: undef)
  • s3_kms_key (Optional[string]) (defaults to: undef)


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
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
# File 'manifests/init.pp', line 27

class splunk (
  String $version,
  String $release,
  String $type,
  String $kernel_version,
  Boolean $adhoc_searchhead,
  Boolean $autolb,
  Integer $autolbfrequency,
  String $cacert,
  Boolean $captain_is_adhoc,
  String $ciphersuite,
  String $cluster_mode,
  String $confdir,
  Boolean $create_user,
  Boolean $deployment_disable,
  Integer $deployment_interval,
  String $dispatch_earliest,
  String $dispatch_latest,
  Integer $dispatch_size,
  String $ecdhcurves,
  String $email,
  String $ext,
  Boolean $forcetimebasedautolb,
  String $install_path,
  Boolean $is_captain,
  String $license_master_mode,
  String $mailserver,
  Boolean $managesecret,
  Integer $max_rawsize_perchunk,
  Integer $max_searches,
  Boolean $preferred_captain,
  String $privkey,
  Boolean $scheduler_disable,
  Integer $search_maxinfocsv,
  Integer $search_maxqueue,
  String $server_site,
  String $servercert,
  String $servercertpass,
  String $source,
  String $group,
  String $user,
  Boolean $replace_hash,
  Boolean $splunknotcp_ssl,
  Boolean $splunknotcp,
  Boolean $sslclientcert,
  Boolean $sslclientcompression,
  Boolean $sslcompression,
  Boolean $sslnegotiation,
  Boolean $sslstsheader,
  Boolean $sslv3,
  Boolean $sslverify,
  String $sslversions,
  Integer $subsearch_maxout,
  Integer $subsearch_maxtime,
  Integer $subsearch_ttl,
  String $symmkey,
  String $tarcmd,
  Boolean $use_mounts,
  Boolean $use_systemd,
  String $webcert,
  Boolean $webssl,
  Enum['v1,v2', 'v2'] $signatureversion,
  Enum['decryptOnly', 'disabled'] $legacyciphers,
  Enum['sse-s3', 'sse-kms', 'sse-c', 'none'] $s3_encryption,
  Optional[String] $license_master,
  Optional[String] $cold_path,
  Optional[String] $warm_path,
  Optional[String] $datamodel_path,
  Integer $maxwarm          = 0,
  Integer $maxcold          = 0,
  Integer $s3_keyrefresh    = 86400,
  Optional[Hash] $acls                = undef,
  Optional[String] $admin_pass        = undef,
  Optional[String] $auth_pass         = undef,
  Optional[String] $authentication    = undef,
  Optional[Hash] $authconfig          = undef,
  Optional[String] $cert_source       = undef,
  Optional[Hash] $indexes             = undef,
  Optional[Hash] $inputs              = undef,
  Optional[Hash] $apps                = undef,
  Optional[String] $geo_source        = undef,
  Optional[String] $geo_hash          = undef,
  Optional[Tuple] $clusters           = undef,
  Optional[String] $deployment_server = undef,
  Optional[Tuple] $licenses           = undef,
  Optional[Integer] $repl_count       = undef,
  Optional[Integer] $repl_port        = undef,
  Optional[Tuple] $roles              = undef,
  Optional[String] $search_deploy     = undef,
  Optional[String] $mailfrom          = undef,
  Optional[String] $serviceurl        = undef,
  Optional[String] $shcluster_label   = undef,
  Optional[String] $shcluster_mode    = undef,
  Optional[Array] $shcluster_members  = undef,
  Optional[Hash] $tcpout              = undef,
  Optional[String] $remote_path       = undef,
  Optional[String] $s3_access_key     = undef,
  Optional[String] $s3_secret_key     = undef,
  Optional[String] $s3_endpoint       = undef,
  Optional[string] $s3_sslverify      = undef,
  Optional[string] $s3_sslversions    = undef,
  Optional[string] $s3_ssl_altname    = undef,
  Optional[string] $s3_ssl_capath     = undef,
  Optional[string] $s3_ciphersuite    = undef,
  Optional[string] $s3_ecdhcurves     = undef,
  Optional[string] $s3_region         = undef,
  Optional[string] $s3_kms_key        = undef
) {
  if $type == 'none' and $facts['splunk_cwd'] != undef {
    exec { 'stop_splunk_service':
      command => "${facts['splunk_cwd']}/bin/splunk stop",
      onlyif  => "${facts['splunk_cwd']}/bin/splunk status",
      path    => '/bin:/usr/bin:/sbin:/usr/sbin',
      before  => File['splunk_installation'],
    }

    file { 'splunk_installation':
      ensure  => absent,
      path    => $facts['splunk_cwd'],
      recurse => true,
      force   => true,
    }
  }

  if $type != 'none' {
    if $environment == 'ci' or $create_user == true {
      class { 'splunk::user': }
    }

    $new_version = "${version}-${release}"
    $kernel = $facts['kernel']
    $arch = $facts['os']['architecture'] ? {
      'x86_64'  => 'x86_64',
      'amd64'   => 'x86_64',
      default => 'i686'
    }

    if $type == 'forwarder' {
      $sourcepart = 'splunkforwarder'
    } else {
      $sourcepart = 'splunk'
    }

    $newsource   = "${sourcepart}-${version}-${release}-${kernel}-${arch}.${ext}"
    $dir      = "${install_path}/${sourcepart}"
    $capath   = "${dir}/etc/auth"
    $confpath = $confdir ? {
      'system' => 'etc/system',
      'app'    => 'etc/apps/__puppet_conf',
      default  => 'etc/system'
    }
    $local    = "${dir}/${confpath}/local"
    $splunkdb = "${dir}/var/lib/splunk"
    $manifest = downcase("${sourcepart}-${new_version}-${kernel}-${kernel_version}-${arch}-manifest")

    # fact containing splunk search head cluster id (if a cluster member)
    # once defined, we add it to our generated files so it is not  lost
    if defined('$splunk_shcluster_id') and $::splunk_shcluster_id =~ String {
      $shcluster_id = $::splunk_shcluster_id
    } else {
      $shcluster_id = undef
    }

    if defined('$splunk_symmkey') and $::splunk_symmkey =~ /^\$\d\$\S+/ and $replace_hash == false {
      $pass4symmkey = $::splunk_symmkey
    } else {
      $pass4symmkey = undef
    }

    if defined('$splunk_certpass') and $::splunk_certpass =~ /^\$\d\$\S+/ and $replace_hash == false {
      $certpass = $::splunk_certpass
    } else {
      $certpass = undef
    }

    # splunk user home dir from fact
    if defined('$splunk_home') and $::splunk_home =~ String {
      $home = $::splunk_home
    } else {
      $home = undef
    }

    # fact showing directory of any running splunk process
    # should match $dir for the type
    if defined('$splunk_cwd') and $::splunk_cwd =~ String {
      $cwd = $::splunk_cwd
    } else {
      $cwd = undef
    }

    # fact is true if splunk/etc and splunk/var are on
    # separate mount points
    if defined('$splunk_mounts') and $::splunk_mounts == true {
      $has_mounts = true
    } else {
      $has_mounts = false
    }

    # splunk is currently installed - get version from fact
    if defined('$splunk_version') and $::splunk_version =~ /^(\d\.)+\d-\w+/ {
      $cur_version = $::splunk_version
      # because the legacy fact does not represent splunk version as
      # version-release, we cut the version from the string.
      $vtemp = regsubst($cur_version, '^((?:\d\.)+\d)-\w+$', '\1')
      $vdiff = versioncmp($version, $vtemp)
      if $cwd =~ /\/\w+\/.*/ {
        # splunk is running from the directory expected for the type
        if $cwd == $dir {
          if $vdiff == 1 {
            info('Upgrading Splunk version.')
            $action = 'upgrade'
          } elsif $vdiff == -1 {
            # current version is higher than the one puppet wants to install
            info('Not downgrading or configuring. Splunk is already at a higher version.')
            $action = 'service'
          } else {
            # version matches - just do config tasks
            $action = 'config'
          }
        } elsif $cwd != $dir and $cwd != $home {
          notice('Changing Splunk install directory.')
          # splunk type changed
          # do not change if no previous splunk install
          # do not change if splunk is running out of the splunk users home
          $action = 'change'
        } else {
          notice('Unhandled splunk_cwd')
        }
      }
    } else {
      # no installed version of splunk from fact
      info('Unhandled splunk_version')
      if ($use_mounts == true and $has_mounts == true) or $use_mounts == false {
        $action = 'install'
      } else {
        info('Wait for mounts')
        $action = 'wait'
      }
      $cur_version = undef
    }

    if $action == 'install' or $action == 'upgrade' or $action == 'change' {
      class { 'splunk::fetch': }
      -> class { 'splunk::install': }
      -> class { 'splunk::config': }
      -> class { 'splunk::service': }
    } elsif $action == 'config' {
      class { 'splunk::config': }
      -> class { 'splunk::service': }
    } elsif $action == 'service' {
      class { 'splunk::service': }
    } elsif $action == 'wait' {
      notice('Waiting for pre-requisites.')
    } else {
      notice('Unhandled action.')
      $action = 'none'
    }

    if $action != 'none' and $action != 'wait' {
      # configure deployment server for indexers and forwarders
      if $type =~ /^(heavy)?forwarder/ and $deployment_server != undef {
        class { 'splunk::deployment': }
      }

      $perms = "${user}:${group}"

      # have Puppet configure Splunk authentication
      if $authentication != undef and $type != 'forwarder' {
        if defined('$splunk_authpass') and $::splunk_authpass =~ /\$\d\$\S+/ {
          $authpass = $::splunk_authpass
        } elsif $auth_pass =~ String {
          $authpass = $auth_pass
        } else {
          $authpass = undef
        }

        class { 'splunk::auth': }
        $auth_dir  = "${local}/auth.d/"
        $auth_conf  = "${local}/authentication.conf"
        $auth_cmd = "/bin/cat ${auth_dir}/* > ${auth_conf}; \
            chown ${perms} ${auth_conf}"

        exec { 'update-auth':
          command     => $auth_cmd,
          refreshonly => true,
          user        => $user,
          group       => $group,
          umask       => '027',
          notify      => Service['splunk'],
        }
      }

      $inputs_dir  = "${local}/inputs.d/"
      $inputs_conf  = "${local}/inputs.conf"
      $inputs_cmd = "/bin/cat ${inputs_dir}/* > ${inputs_conf}; \
          chown ${perms} ${inputs_conf}"

      exec { 'update-inputs':
        command     => $inputs_cmd,
        refreshonly => true,
        user        => $user,
        group       => $group,
        umask       => '027',
        notify      => Service['splunk'],
      }

      if $type != 'forwarder' or $deployment_server == undef {
        if $type != 'indexer' and $tcpout =~ Hash {
          $outputs_dir = "${local}/outputs.d/"
          $outputs_conf = "${local}/outputs.conf"
          $outputs_cmd = "/bin/cat ${outputs_dir}/* > ${outputs_conf}; \
              chown ${perms} ${outputs_conf}"

          exec { 'update-outputs':
            command     => $outputs_cmd,
            refreshonly => true,
            user        => $user,
            group       => $group,
            umask       => '027',
            notify      => Service['splunk'],
          }
        }

        if ($type == 'indexer' or $type == 'index_master' or $type == 'standalone') and $indexes =~ Hash {
          $indexes_dir = "${local}/indexes.d/"
          if $splunk::cluster_mode == 'master' {
            $indexes_conf_dir = "${dir}/etc/master-apps/_cluster/local"
          } else {
            $indexes_conf_dir = $local
          }
          $indexes_conf = "${indexes_conf_dir}/indexes.conf"
          $indexes_cmd = "/bin/cat ${indexes_dir}/* > ${indexes_conf}; \
              chown ${perms} ${indexes_conf}"

          exec { 'update-indexes':
            command     => $indexes_cmd,
            refreshonly => true,
            user        => $user,
            group       => $group,
            umask       => '027',
            notify      => Service['splunk'],
          }
        }

        $server_dir = "${local}/server.d/"
        $server_conf = "${local}/server.conf"
        $server_cmd = "/bin/cat ${server_dir}/* > ${server_conf}; \
            chown ${perms} ${server_conf}"

        exec { 'update-server':
          command     => $server_cmd,
          refreshonly => true,
          user        => $user,
          group       => $group,
          umask       => '027',
          notify      => Service['splunk'],
        }
      }
    }
  }
}