Defined Type: kibana::plugin

Defined in:
manifests/plugin.pp

Overview

Define kibana::plugin

Defined type to manage kibana plugins

Parameters:

  • source (Any)
  • ensure (Any) (defaults to: 'present')
  • install_root (Any) (defaults to: $::kibana::install_path)
  • group (Any) (defaults to: $::kibana::group)
  • user (Any) (defaults to: $::kibana::user)


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

define kibana::plugin(
  $source,
  $ensure       = 'present',
  $install_root = $::kibana::install_path,
  $group        = $::kibana::group,
  $user         = $::kibana::user) {

  # plugins must be formatted <org>/<plugin>/<version>
  $filenameArray = split($source, '/')
  $base_module_name = $filenameArray[-2]

  # borrowed heavily from https://github.com/elastic/puppet-elasticsearch/blob/master/manifests/plugin.pp
  $plugins_dir = "${install_root}/kibana/installedPlugins"
  $install_cmd = "kibana plugin --install ${source}"
  $uninstall_cmd = "kibana plugin --remove ${base_module_name}"

  Exec {
    path      => [ '/bin', '/usr/bin', '/usr/sbin', "${install_root}/kibana/bin" ],
    cwd       => '/',
    user      => $user,
    tries     => 6,
    try_sleep => 10,
    timeout   => 600,
  }

  case $ensure {
    'installed', 'present': {
      $name_file_path = "${plugins_dir}/${base_module_name}/.name"
      exec {"install_plugin_${name}":
        command => $install_cmd,
        creates => $name_file_path,
        notify  => Service['kibana'],
        require => File[$plugins_dir],
      }
      file {$name_file_path:
        ensure  => file,
        content => $base_module_name,
        require => Exec["install_plugin_${base_module_name}"],
      }
    }
    'absent': {
      exec {"remove_plugin_${base_module_name}":
        command => $uninstall_cmd,
        onlyif  => "test -f ${name_file_path}",
        notify  => Service['kibana'],
      }
    }
    default: {
      fail("${ensure} is not a valid ensure command.")
    }
  }
}