Defined Type: sensu::mutator

Defined in:
manifests/mutator.pp

Summary

Manages sensu mutators

Overview

This define manages Sense mutators

Parameters:

  • ensure (Enum['present','absent']) (defaults to: 'present')

    Whether the check should be present or not

  • command (String)

    Command to run.

  • timeout (Optional[Numeric]) (defaults to: undef)

    The mutator execution duration timeout in seconds (hard stop).

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

    Source of the puppet mutator

  • install_path (Stdlib::Absolutepath) (defaults to: '/etc/sensu/mutators')

    Path to install the mutator



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
58
59
60
61
62
63
64
65
66
67
# File 'manifests/mutator.pp', line 15

define sensu::mutator(
  String $command,
  Enum['present','absent'] $ensure   = 'present',
  Optional[Numeric] $timeout         = undef,
  # Used to install the mutator
  Optional[String] $source           = undef,
  Stdlib::Absolutepath $install_path = '/etc/sensu/mutators',
) {

  assert_type(Pattern[/^[\w\.-]+$/], $name)

  include ::sensu

  if $::sensu::server {
    $notify_services = Class['sensu::server::service']
  } else {
    $notify_services = []
  }

  if $source {
    $mutator = "${install_path}/${basename($source)}"

    $file_ensure = $ensure ? {
      'absent' => 'absent',
      default  => 'file'
    }

    file { $mutator:
      ensure => $file_ensure,
      owner  => 'sensu',
      group  => 'sensu',
      mode   => '0555',
      source => $source,
    }
  } else {
    $file_ensure = undef
  }

  file { "${::sensu::conf_dir}/mutators/${name}.json":
    ensure => $file_ensure,
    owner  => 'sensu',
    group  => 'sensu',
    mode   => '0440',
    before => Sensu_mutator[$name],
  }

  sensu_mutator { $name:
    ensure  => $ensure,
    command => $command,
    timeout => $timeout,
    require => File["${::sensu::conf_dir}/mutators"],
  }
}