Puppet Class: sensu::plugins

Defined in:
manifests/plugins.pp

Summary

Manage Sensu plugins

Overview

Class to manage the Sensu plugins.

Examples:

class { 'sensu::plugins':
  plugins    => ['disk-checks'],
  extensions => ['graphite'],
}
class { 'sensu::plugins':
  plugins    => {
    'disk-checks' => { 'version' => 'latest' },
  },
  extensions => {
    'graphite' => { 'version' => 'latest' },
  },
}

Parameters:

  • manage_repo (Optional[Boolean]) (defaults to: undef)

    Determines if plugin repo should be managed. Defaults to value for sensu::manage_repo.

  • package_ensure (String) (defaults to: 'installed')

    Ensure property for sensu plugins package.

  • package_name (String) (defaults to: 'sensu-plugins-ruby')

    Name of the Sensu plugins ruby package.

  • dependencies (Array) (defaults to: [])

    Package dependencies needed to install plugins and extensions. Default is OS dependent.

  • gem_dependencies (Array) (defaults to: [])

    Gem dependencies.

  • plugins (Variant[Array, Hash]) (defaults to: [])

    Plugins to install

  • extensions (Variant[Array, Hash]) (defaults to: [])

    Extensions to install



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

class sensu::plugins (
  Optional[Boolean] $manage_repo = undef,
  String $package_ensure = 'installed',
  String $package_name = 'sensu-plugins-ruby',
  Array $dependencies = [],
  Array $gem_dependencies = [],
  Variant[Array, Hash] $plugins = [],
  Variant[Array, Hash] $extensions = [],
) {

  if $facts['os']['family'] == 'windows' {
    fail('sensu::plugins is not supported on Windows')
  }

  include sensu
  include sensu::common

  $_manage_repo = pick($manage_repo, $sensu::manage_repo)

  if $_manage_repo {
    include sensu::repo::community
    $package_require = [Class['sensu::repo::community']] + $sensu::os_package_require
  } else {
    $package_require = undef
  }

  package { 'sensu-plugins-ruby':
    ensure  => $package_ensure,
    name    => $package_name,
    require => $package_require,
  }

  ensure_packages($dependencies)
  $dependencies.each |$package| {
    Package[$package] -> Sensu_plugin <| |> # lint:ignore:spaceship_operator_without_tag
  }
  ensure_packages($gem_dependencies, {'provider' => 'sensu_gem', 'require' => [Package[$dependencies],Package['sensu-plugins-ruby']]})

  if $plugins =~ Array {
    $plugins.each |$plugin| {
      sensu_plugin { $plugin:
        ensure => 'present',
      }
    }
  } else {
    $plugins.each |$plugin, $plugin_data| {
      $data = { 'ensure' => 'present' } + $plugin_data
      sensu_plugin { $plugin:
        * => $data,
      }
    }
  }

  if $extensions =~ Array {
    $extensions.each |$extension| {
      sensu_plugin { $extension:
        ensure    => 'present',
        extension => true,
      }
    }
  } else {
    $extensions.each |$extension, $extension_data| {
      $data = { 'ensure' => 'present', 'extension' => true } + $extension_data
      sensu_plugin { $extension:
        * => $data,
      }
    }
  }

}