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
|
# File 'modules/prometheus/manifests/cluster_config.pp', line 25
define prometheus::cluster_config(
String $dest,
String $cluster,
Stdlib::Port $port,
Hash $labels,
) {
$data = wmflib::get_clusters({'site' => [$::site], 'cluster' => [$cluster]}).map |$cluster_items| {
# $cluster_items is a tuple of ($cluster, $sites)
$cluster_items[1].map |$site_items| {
# $site_items is a tuple of ($site, $targets)
$targets = $site_items[1].map |$target| { "${target.split('\.')[0]}:${port}" }.sort
$item = {
'targets' => $targets,
# TODO: should we add {'cluster' => $cluster} to labels?
'labels' => $labels,
}
$item
}
}.flatten
file { $dest:
ensure => stdlib::ensure(!$data.empty, 'file'),
owner => 'root',
group => 'root',
mode => '0444',
content => "# This file is managed by puppet\n${data.to_yaml}\n"
}
}
|