Defined Type: prometheus::pdu_config_netbox

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

Overview

Parameters:

  • dest (String)
  • pdus (Hash[String[3], Netbox::Device::PDU])
  • name_matcher (String)
  • model_matcher (String)
  • manufacturer (String)
  • labels (Hash) (defaults to: {})


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
# File 'modules/prometheus/manifests/pdu_config_netbox.pp', line 15

define prometheus::pdu_config_netbox(
    String $dest,
    Hash[String[3], Netbox::Device::PDU] $pdus,
    String $name_matcher,
    String $model_matcher,
    String $manufacturer,
    Hash   $labels       = {},
) {

    $pdus_filtered = $pdus.filter |$pdu, $config| {
            ($config['location']['site'] == $::site)
            and
            ($config['manufacturer'] == $manufacturer)
            and
            (!empty(match($pdu, $name_matcher)))
            and
            (!empty(match($config['model'], $model_matcher)))
    }

    $pdu_resources = $pdus_filtered.map |$pdu, $config| {
        {
            'title'      => $pdu,
            'parameters' => {
                'site' => $config['location']['site'],
                'row'  => $config['location']['row'],
            }
        }

    }

    file { $dest:
        ensure  => present,
        mode    => '0444',
        content => template('prometheus/pdu_config.erb'),
    }
}