Puppet Class: netops::atlasexporter

Defined in:
modules/netops/manifests/atlasexporter.pp

Overview

Parameters:

  • atlas_measurements (Hash[String, Hash])
  • exporter_port (Stdlib::Port)


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
# File 'modules/netops/manifests/atlasexporter.pp', line 11

class netops::atlasexporter(
    Hash[String, Hash] $atlas_measurements,
    Stdlib::Port $exporter_port,
) {
    require_package('prometheus-atlas-exporter')

    $config_file = '/etc/prometheus-atlas-exporter.yaml'

    # For the exporter, we need to write out key=>value pairs of key 'id'
    # and value of the measurement ID.
    $measurement_ids = $atlas_measurements.reduce([]) |$acc, $elem| {
        concat($acc, [{'id' => $elem[1]['ipv4']},
                      {'id' => $elem[1]['ipv6']}])
    }

    file { $config_file:
        ensure  => 'file',
        content => to_yaml({'measurements' => $measurement_ids}),
        owner   => 'prometheus',
        notify  => Systemd::Service['prometheus-atlas-exporter'],
    }

    systemd::service { 'prometheus-atlas-exporter':
        ensure  => 'present',
        content => systemd_template('prometheus-atlas-exporter'),
        require => [ Package['prometheus-atlas-exporter'], File[$config_file] ],
        restart => true,
    }
}