sensu puppet module and check definitions

Hey guys,

I’m running into a wall doing something which should be pretty simple. I’m trying to install plugins and then use them for checks using puppet.

It looks like when we install sensu plugins via sensu_gem, there’s no way of knowing from a puppet perspective what the path to the gem actually is. I would expect once we’ve installed a plugin using sensu_gem, that we would not have to provide a fully qualified path to the files installed by that gem. It basically makes the sensu_gem provider totally useless for automating plugin/check deployment.

Since I assume it is not totally useless, I am clearly doing something wrong.

Here’s the manifest:

$config[‘checks’].each |$check| {

if ($check[‘plugin’] and !defined(Package[$check[‘plugin’]])) {

package { $check[‘plugin’]:

provider => sensu_gem;

}

}

sensu::check {

$check[‘name’]:

handlers => $check[‘handlers’],

command => $check[‘command’],

interval => $check[‘interval’],

standalone => true

}

}

``

Here’s the hiera:
checks:

  • name: ‘disk-usage’

handlers:

  • ‘default’

plugin: ‘sensu-plugins-disk-checks’

command: ‘check-disk-usage.rb -w :::disk.warning|90::: -c :::disk.critical|95:::’

interval: 60

``

You can see why I would expect that to work. Instead I get ‘sh: 1: check-disk-usage.rb: not found’ from sensu.

The path the file can be found at is /opt/sensu/embedded/lib/ruby/gems/2.2.0/gems/sensu-plugins-disk-checks-0.0.1/bin, which means to use that path I would have to pin version numbers for every check.

Here’s the check definition that puppet created:
{

“checks”: {

“disk-usage”: {

“command”: “check-disk-usage.rb -w :::disk.warning|90::: -c :::disk.critical|95:::”,

“handlers”: [

“default”

],

“interval”: 60,

“standalone”: true

}

}

}

``

What am I missing? I have embedded_ruby set to true.

Naturally, as one does when they cry for help, I found a solution.

I changed the following:

Here’s the manifest:

$config[‘checks’].each |$check| {

if ($check[‘plugin’] and !defined(Package[$check[‘plugin’]])) {

package { $check[‘plugin’]:

provider => sensu_gem;

}

}

sensu::check {

$check[‘name’]:

handlers => $check[‘handlers’],

command => $check[‘command’],

interval => $check[‘interval’],

standalone => true

}

}

``

To:
$config[‘checks’].each |$check| {

if ($check[‘plugin’] and !defined(Package[$check[‘plugin’]])) {

sensu::plugin { $check[‘plugin’]:

pkg_provider => ‘sensu_gem’,

type => ‘package’,

}

}

sensu::check {

$check[‘name’]:

handlers => $check[‘handlers’],

command => $check[‘command’],

interval => $check[‘interval’],

standalone => true

}

}

``

That resulted in:
Notice: /Stage[main]/Profile::Sensu::Client/Sensu::Plugin[sensu-plugins-disk-checks]/Package[sensu-plugins-disk-checks]/ensure: ensure changed ‘[“0.0.1”]’ to ‘1.1.3’

Notice: /Stage[main]/Profile::Sensu::Client/Sensu::Check[disk-usage]/Sensu_check[disk-usage]/command: command changed ‘/opt/sensu/embedded/bin/ruby check-disk-usage.rb -w :::disk.warning|90::: -c :::disk.critical|95:::’ to ‘check-disk-usage.rb -w :::disk.warning|90::: -c :::disk.critical|95:::’

Info: /Stage[main]/Profile::Sensu::Client/Sensu::Check[disk-usage]/Sensu_check[disk-usage]: Scheduling refresh of Service[sensu-client]

Info: /Stage[main]/Profile::Sensu::Client/Sensu::Check[disk-usage]/Sensu_check[disk-usage]: Scheduling refresh of Service[sensu-server]

Notice: /Stage[main]/Sensu::Client::Service/Service[sensu-client]: Triggered ‘refresh’ from 1 events

Notice: /Stage[main]/Sensu::Server::Service/Service[sensu-server]: Triggered ‘refresh’ from 1 events

Notice: Applied catalog in 29.83 seconds

``

Looks like the wrong version was getting pinned there with the regular package provider.

TL;DR: used sensu::plugin instead of package { ‘plugin’: provider => sensu_gem }