Defined Type: prometheus::class_config

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

Overview

Parameters:

  • dest (String)
  • class_name (String)
  • port (Stdlib::Port)
  • labels (Hash) (defaults to: {})
  • class_parameters (Hash) (defaults to: {})
  • hostnames_only (Boolean) (defaults to: true)
  • ensure (Wmflib::Ensure) (defaults to: present)


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

define prometheus::class_config(
    String $dest,
    String $class_name,
    Stdlib::Port $port,
    Hash $labels = {},
    Hash $class_parameters = {},
    Boolean $hostnames_only = true,
    Wmflib::Ensure $ensure = present,
) {
    $_class_name = wmflib::resource::capitalize($class_name)
    $parameters_query = $class_parameters.map |$k, $v| {
        $_v = $v ? {
            String  => "\"${v}\"",
            default => $v,
        }
        "parameters.${k} = ${_v}"
    }.join(' and ')
    $_parameters_query = $class_parameters.empty.bool2str('',"and ${parameters_query}")
    $pql = @("PQL")
    resources[certname] {
        type = "Class" and title = "${_class_name}"
        ${_parameters_query}
        order by certname
    }
    | PQL
    $servers = wmflib::puppetdb_query($pql).map  |$x| { $x['certname'] }
    $site_clusters = wmflib::get_clusters({'site' => [$::site]})

    file { $dest:
        ensure  => stdlib::ensure($ensure, 'file'),
        owner   => 'root',
        group   => 'root',
        mode    => '0444',
        content => template('prometheus/class_config.erb'),
    }
}