Puppet Class: profile::wmcs::metricsinfra::alertmanager

Defined in:
modules/profile/manifests/wmcs/metricsinfra/alertmanager.pp

Overview

Parameters:

  • projects (Array[Hash]) (defaults to: lookup('profile::wmcs::metricsinfra::monitored_projects'))
  • alertmanager_hosts (Array[Stdlib::Fqdn]) (defaults to: lookup('profile::wmcs::metricsinfra::prometheus_alertmanager_hosts'))


1
2
3
4
5
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
# File 'modules/profile/manifests/wmcs/metricsinfra/alertmanager.pp', line 1

class profile::wmcs::metricsinfra::alertmanager (
    Array[Hash]  $projects = lookup('profile::wmcs::metricsinfra::monitored_projects'),
    Array[Stdlib::Fqdn] $alertmanager_hosts = lookup('profile::wmcs::metricsinfra::prometheus_alertmanager_hosts'),
) {
    $base_path = '/etc/prometheus/alertmanager'

    # Prometheus alert manager service setup and config
    package { 'prometheus-alertmanager':
        ensure => present,
    }

    service { 'prometheus-alertmanager':
        ensure => running,
    }

    exec { 'alertmanager-reload':
        command     => '/bin/systemctl reload prometheus-alertmanager',
        refreshonly => true,
    }

    exec { 'alertmanager-restart':
        command     => '/bin/systemctl restart prometheus-alertmanager',
        refreshonly => true,
    }

    $listen_address = $::ipaddress
    $peers = $alertmanager_hosts.filter |Stdlib::Fqdn $host| {
        $host != $::fqdn
    }.map |Stdlib::Fqdn $host| {
        "${host}:9094"
    }

    file { '/etc/default/prometheus-alertmanager':
        content => template('profile/wmcs/metricsinfra/prometheus-alertmanager-defaults.erb'),
        owner   => 'root',
        group   => 'root',
        mode    => '0444',
        notify  => Exec['alertmanager-restart'],
    }

    file { $base_path:
        ensure => directory,
        owner  => 'root',
        group  => 'root',
    }

    file { "${base_path}/alertmanager.yml":
        content => template('profile/wmcs/metricsinfra/alertmanager.yml.erb'),
        owner   => 'root',
        group   => 'root',
        mode    => '0444',
        notify  => Exec['alertmanager-reload'],
    }
}