Puppet Class: alerts::deploy::prometheus

Defined in:
modules/alerts/manifests/deploy/prometheus.pp

Overview

SPDX-License-Identifier: Apache-2.0 Deploy alerts from $git_repo to $deploy_dir for Prometheus to pick up.

Parameters:

  • deploy_dir (Stdlib::Unixpath) (defaults to: '/srv/alerts')
  • git_dir (Stdlib::Unixpath) (defaults to: '/srv/alerts.git')
  • git_repo (String[1]) (defaults to: 'operations/alerts')
  • git_source (String[1]) (defaults to: 'gerrit')
  • git_branch (String[1]) (defaults to: 'master')
  • instances (Array[String[1]]) (defaults to: [])


3
4
5
6
7
8
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
# File 'modules/alerts/manifests/deploy/prometheus.pp', line 3

class alerts::deploy::prometheus (
    Stdlib::Unixpath $deploy_dir = '/srv/alerts',
    Stdlib::Unixpath $git_dir    = '/srv/alerts.git',
    String[1]        $git_repo   = 'operations/alerts',
    String[1]        $git_source = 'gerrit',
    String[1]        $git_branch = 'master',
    Array[String[1]] $instances  = [],
) {
    require ::alerts

    alerts::deploy::instance { 'local':
        alerts_dir    => $git_dir,
        deploy_dir    => $deploy_dir,
        deploy_site   => $::site,
        git_repo_name => $git_repo,
    }

    # Deploy instance-specific alerts
    $instances.each |$instance| {
        alerts::deploy::instance { $instance:
            alerts_dir    => $git_dir,
            deploy_dir    => "${deploy_dir}/${instance}",
            deploy_tag    => $instance,
            deploy_site   => $::site,
            git_repo_name => $git_repo,
        }
    }

    git::clone { $git_repo:
        ensure    => latest,
        directory => $git_dir,
        source    => $git_source,
        branch    => $git_branch,
        notify    => Exec['start alerts-deploy'],
    }

    exec { 'start alerts-deploy':
        command     => '/bin/systemctl start alerts-deploy.target',
        refreshonly => true,
        notify      => Exec['reload all prometheus instances'],
    }

    exec { 'reload all prometheus instances':
        command     => '/bin/systemctl reload prometheus@*',
        refreshonly => true,
    }
}