Puppet Class: ganeti::prometheus

Defined in:
modules/ganeti/manifests/prometheus.pp

Overview

Parameters:



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
64
65
# File 'modules/ganeti/manifests/prometheus.pp', line 7

class ganeti::prometheus(
    String $rapi_endpoint,
    String $rapi_ro_user,
    String $rapi_ro_password,
) {
    ensure_packages([
        'prometheus-ganeti-exporter',
        'python3-cryptography',
        'python3-prometheus-client',
    ])

    firewall::service {'ganeti-prometheus-exporter':
        proto    => 'tcp',
        port     => 8080,
        src_sets => ['PRODUCTION_NETWORKS'],
    }

    # Configuration files for Ganeti Prometheus exporter
    file { '/etc/ganeti/prometheus.ini':
        ensure  => present,
        owner   => 'prometheus',
        group   => 'prometheus',
        mode    => '0400',
        content => template('ganeti/prometheus-collector.erb')
    }

    file { '/usr/local/sbin/prometheus-ganeti-ca-exporter' :
        ensure => present,
        mode   => '0544',
        source => 'puppet:///modules/ganeti/prometheus-ganeti-ca-exporter.py',
    }

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

    profile::auto_restarts::service { 'prometheus-ganeti-exporter': }

    systemd::timer::job { 'prometheus-ganeti-ca-exporter':
        ensure      => stdlib::ensure($facts['ganeti_master'] == $facts['networking']['fqdn']),
        user        => 'root',
        description => 'Exports Prometheus metrics about the internal Ganeti CA',
        command     => "/usr/local/sbin/prometheus-ganeti-ca-exporter --outfile /var/lib/prometheus/node.d/ganeti-ca.prom --cert-path /var/lib/ganeti/server.pem --clustername ${rapi_endpoint}",
        interval    => {
            'start'    => 'OnCalendar',
            'interval' => 'daily',
        },
    }

    # The CA validity check is only run on the current Ganeti master
    # But after a Ganeti master failover a stale .prom file is left behind,
    # which triggers the generic NodeTextfileStale alert. As such, remove
    # it everywhere except on the current Ganeti master.
    unless stdlib::ensure($facts['ganeti_master'] == $facts['networking']['fqdn']) {
        file { '/var/lib/prometheus/node.d/ganeti-ca.prom':
            ensure  => absent,
        }
    }
}