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

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

Overview

SPDX-License-Identifier: Apache-2.0

Parameters:

  • alertmanager_hosts (Array[Stdlib::Fqdn]) (defaults to: lookup('profile::wmcs::metricsinfra::prometheus_alertmanager_hosts'))
  • active_host (Stdlib::Fqdn) (defaults to: lookup('profile::wmcs::metricsinfra::alertmanager_active_host'))


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
55
56
57
58
59
60
61
62
63
# File 'modules/profile/manifests/wmcs/metricsinfra/alertmanager.pp', line 2

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

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

    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'],
    }

    # prometheus_configurator will manage the directory contents, but
    # it still needs to exist and be writable
    file { $base_path:
        ensure => directory,
        owner  => 'prometheus',
        group  => 'prometheus',
    }

    # TODO: instead of providing the config base, split into small
    # parts and fit into the base prometheus_configurator.pp config
    file { '/etc/prometheus-configurator/config.d/alertmanager-base.yaml':
        content => template('profile/wmcs/metricsinfra/alertmanager.yml.erb'),
        owner   => 'root',
        group   => 'root',
        mode    => '0444',
    }

    profile::wmcs::metricsinfra::prometheus_configurator::output_config { 'alertmanager':
        kind    => 'alertmanager',
        options => {
            base_directory  => $base_path,
            units_to_reload => [
                'prometheus-alertmanager.service',
            ]
        },
    }

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