Puppet Class: statograph

Defined in:
modules/statograph/manifests/init.pp

Summary

Installs statograph and configures systemd timer

Overview

SPDX-License-Identifier: Apache-2.0

Parameters:

  • api_key (Sensitive[String[1]]) (defaults to: '')

    the api key for statuspage.io

  • page_id (Sensitive[String[1]]) (defaults to: '')

    the statuspage “page id” for the WMF main page

  • ensure (Wmflib::Ensure) (defaults to: 'ensure')

    the ensureable parameter

  • owner (String) (defaults to: 'root')

    all files created by this module will be owned by this user

  • group (String) (defaults to: 'root')

    all files created by this module will be owned by this group

  • mode (Stdlib::Filemode) (defaults to: '0500')

    all files created by this module will be managed with this mode

  • proxies (Hash[String, Statograph::Proxy]) (defaults to: {})
  • metrics (Array[Statograph::Metric]) (defaults to: [])


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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'modules/statograph/manifests/init.pp', line 10

class statograph (
    Wmflib::Ensure                  $ensure  = 'ensure',
    Sensitive[String[1]]            $api_key = '',
    Sensitive[String[1]]            $page_id = '',
    String                          $owner   = 'root',
    String                          $group   = 'root',
    Stdlib::Filemode                $mode    = '0500',
    Hash[String, Statograph::Proxy] $proxies = {},
    Array[Statograph::Metric]       $metrics = [],
)
{
    $config_file = '/etc/statograph/config.yml'
    $job_command = "/usr/bin/statograph -c ${config_file} upload_metrics"

    ensure_packages('statograph', {'ensure' => $ensure})

    $config = {
        'statuspage' => {
            'api_key' => $api_key.unwrap,
            'page_id' => $page_id.unwrap,
        },
        'proxies'    => $proxies,
        'metrics'   => $metrics,
    }

    file {'/etc/statograph':
        ensure => stdlib::ensure($ensure, 'directory'),
        owner  => $owner,
        group  => $group,
        mode   => $mode,
    }

    file {$config_file:
        ensure  => stdlib::ensure($ensure, 'file'),
        owner   => $owner,
        group   => $group,
        mode    => $mode,
        content => $config.to_yaml,
        require => Package['statograph'],
    }

    systemd::timer::job { 'statograph_post':
        ensure             => $ensure,
        description        => 'Runs statograph to publish data to statuspage.io',
        user               => $owner,
        monitoring_enabled => true,
        command            => $job_command,
        interval           => {'start' => 'OnCalendar', 'interval' => 'minutely'},
        require            => [
            File[$config_file],
            Package['statograph'],
        ]
    }

}