Defined Type: sensu::plugin

Defined in:
manifests/plugin.pp

Summary

Installs Sensu plugins

Overview

Installs the Sensu community script and plugins which can be used as monitoring checks

Parameters:

  • type (Enum['file','url','package','directory']) (defaults to: 'file')

    Plugin source Valid values: file, directory, package, url

  • install_path (Stdlib::Absolutepath) (defaults to: $::osfamily)

    The path to install the plugin

  • purge (Boolean) (defaults to: true)

    When using a directory source, purge setting

  • recurse (Boolean) (defaults to: true)

    When using a directory source, recurse setting

  • force (Boolean) (defaults to: true)

    When using a directory source, force setting

  • pkg_version (Pattern[/^absent$/,/^installed$/,/^latest$/,/^present$/,/^[\d\.\-]+$/]) (defaults to: 'latest')

    When using package source, version to install

  • pkg_provider (Optional[String]) (defaults to: $::sensu::sensu_plugin_provider)

    When using package to install plugins, provider to use. Valid values: sensu_gem, apt, aptitude, yum

  • pkg_checksum (Optional[String]) (defaults to: undef)

    The packake's MD5 checksum. Valid values: Any valid MD5 string of the wanted package

  • nocheckcertificate (Boolean) (defaults to: false)

    When using url source, disable certificate checking for HTTPS

  • gem_install_options (Any) (defaults to: $::sensu::gem_install_options)

    Optional configuration to use for the installation of the sensu plugin gem with sensu_gem provider. See: https://docs.puppetlabs.com/references/latest/type.html#package-attribute-install_options Example value: [{ '-p' => 'http://user:pass@myproxy.company.org:8080' }]



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

define sensu::plugin (
  Enum['file','url','package','directory'] $type                = 'file',
  Stdlib::Absolutepath $install_path = $::osfamily ? {
    'windows' => 'C:/opt/sensu/plugins',
    default   => '/etc/sensu/plugins',
  },
  Boolean $purge               = true,
  Boolean $recurse             = true,
  Boolean $force               = true,
  Pattern[/^absent$/,/^installed$/,/^latest$/,/^present$/,/^[\d\.\-]+$/] $pkg_version         = 'latest',
  Optional[String] $pkg_provider        = $::sensu::sensu_plugin_provider,
  Optional[String] $pkg_checksum        = undef,
  Boolean $nocheckcertificate  = false,
  Any $gem_install_options = $::sensu::gem_install_options,
) {

  File {
    owner => 'sensu',
    group => 'sensu',
  }

  Sensu::Plugin[$name]
  ~> Service['sensu-client']

  # (#463) All plugins must come before all checks.  Collections are not used to
  # avoid realizing any resources.
  Sensu::Plugin[$name]
  -> Anchor['plugins_before_checks']

  case $type {
    'file': {
      $filename = basename($name)

      sensu::plugins_dir { "${name}-${install_path}":
        path    => $install_path,
        purge   => $purge,
        recurse => $recurse,
        force   => $force,
      }

      file { "${install_path}/${filename}":
        ensure  => file,
        mode    => '0555',
        source  => $name,
        require => File[$install_path],
      }
    }
    'url': {
      $filename = basename($name)

      sensu::plugins_dir { "${name}-${install_path}":
        path    => $install_path,
        purge   => $purge,
        recurse => $recurse,
        force   => $force,
      }

      remote_file { $name:
        ensure   => present,
        path     => "${install_path}/${filename}",
        source   => $name,
        checksum => $pkg_checksum,
        require  => File[$install_path],
      }

      file { "${install_path}/${filename}":
        ensure  => file,
        mode    => '0555',
        require => [
          File[$install_path],
          Remote_file[$name],
        ],
      }
    }
    'directory': {
      file { "${install_path}_for_plugin_${name}":
        ensure  => 'directory',
        path    => $install_path,
        mode    => '0555',
        source  => $name,
        recurse => $recurse,
        purge   => $purge,
        force   => $force,
        require => Package[$sensu::package::pkg_title],
      }
    }
    'package': {
      $gem_install_options_real = $pkg_provider ? {
        'gem'       => $gem_install_options,
        'sensu_gem' => $gem_install_options,
        default     => undef,
      }

      package { $name:
        ensure          => $pkg_version,
        provider        => $pkg_provider,
        install_options => $gem_install_options_real,
      }
    }
    default:      {
      fail('Unsupported sensu::plugin install type')
    }
  }
}