Puppet Class: prometheus::blackbox_exporter

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

Overview

Parameters:

  • http_proxy (Optional[Stdlib::HTTPUrl]) (defaults to: undef)


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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'modules/prometheus/manifests/blackbox_exporter.pp', line 9

class prometheus::blackbox_exporter(
    Optional[Stdlib::HTTPUrl] $http_proxy = undef,
) {

    # Grant permissions to send out ICMP probes
    debconf::set { 'prometheus-blackbox-exporter/want_cap_net_raw':
        type   => 'boolean',
        value  => true,
        before => Package['prometheus-blackbox-exporter'],
    }

    package { 'prometheus-blackbox-exporter':
        ensure => present,
    }

    file { '/etc/prometheus/blackbox.yml.d':
        ensure  => directory,
        mode    => '0555',
        owner   => 'root',
        group   => 'root',
        recurse => true,
        purge   => true,
    }

    file { '/usr/local/bin/blackbox-exporter-assemble':
        ensure => present,
        mode   => '0555',
        owner  => 'root',
        group  => 'root',
        source => 'puppet:///modules/prometheus/blackbox_exporter/assemble_config.py',
        before => Exec['assemble blackbox.yml'],
    }

    ['misc', 'common'].each |$frag| {
        prometheus::blackbox::module { $frag:
            content => template("prometheus/blackbox_exporter/${frag}.yml.erb"),
        }
    }

    # The exec is always run (gated by onlyif) to be able to recover from the following scenario:
    # - a fragment changes, a refresh of this exec is triggered
    # - the exec fails for some reason, the configuration is not updated
    # - at the next puppet run the fragment doesn't change, therefore the exec is not refreshed again
    # - the old configuration is silently kept in place until a fragment changes again

    exec { 'assemble blackbox.yml':
        onlyif  => 'blackbox-exporter-assemble --onlyif',
        command => 'blackbox-exporter-assemble',
        notify  => Service['prometheus-blackbox-exporter'],
        path    => '/usr/local/bin',
    }

    systemd::service { 'prometheus-blackbox-exporter':
        ensure   => present,
        content  => init_template('prometheus-blackbox-exporter', 'systemd_override'),
        override => true,
        restart  => true,
    }

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

    logrotate::conf { 'blackbox_exporter':
        ensure => present,
        source => 'puppet:///modules/prometheus/blackbox_exporter.logrotate.conf',
    }

    rsyslog::conf { 'blackbox_exporter':
        source   => 'puppet:///modules/prometheus/blackbox_exporter.rsyslog.conf',
        priority => 40,
    }
}