Puppet Class: ncmonitor

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

Overview

Parameters:

  • ensure (Wmflib::Ensure)
  • nameservers (Array[Stdlib::Host])
  • markmon_api_user (String)
  • markmon_api_pass (String)
  • http_proxy (Optional[Stdlib::HTTPUrl])


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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'modules/ncmonitor/manifests/init.pp', line 34

class ncmonitor(
    Wmflib::Ensure            $ensure,
    Array[Stdlib::Host]       $nameservers,
    String                    $markmon_api_user,
    String                    $markmon_api_pass,
    Optional[Stdlib::HTTPUrl] $http_proxy,
) {
    $config = {
        nameservers => $nameservers,
        markmonitor => {
            username => $markmon_api_user,
            password => $markmon_api_pass,
        },
    }

    package { 'ncmonitor':
        ensure  => $ensure,
    }

    systemd::sysuser { 'ncmonitor':
        ensure   => $ensure,
        shell    => '/bin/sh',
        home_dir => '/nonexistent',
    }

    $ensure_conf_dir = $ensure ? {
        absent  => $ensure,
        default => 'directory',
    }

    file { '/etc/ncmonitor/':
        ensure => $ensure_conf_dir,
        owner  => 'ncmonitor',
        group  => 'root',
        mode   => '0700',
    }

    file { '/etc/ncmonitor/ncmonitor.yaml':
        ensure    => $ensure,
        owner     => 'ncmonitor',
        group     => 'root',
        mode      => '0400',
        content   => to_yaml($config),
        require   => Package['ncmonitor'],
        backup    => false,
        show_diff => false,
    }

    # Some environments (e.g. WMCS) should not have proxies set. Merely setting
    # a default value for the 'environment' attribute would cause empty
    # Environment= entries to be created. We need to either specify
    # 'environment' with values or not at all.
    $timer_defaults = {
        ensure      => $ensure,
        user        => 'ncmonitor',
        description => 'Verify/Sync non-canonical domains with downstream services',
        command     => '/usr/bin/ncmonitor',
        interval    => {
            'start'    => 'OnCalendar',
            'interval' => 'daily',
        },
        require     => Package['ncmonitor'],
    }

    $timer = $http_proxy? {
        Stdlib::HTTPUrl => {
            'ncmonitor' => {
                environment => {
                    'HTTP_PROXY'  => $http_proxy,
                    'HTTPS_PROXY' => $http_proxy,
                }
            }
        },
        default         => {'ncmonitor' => {}},
    }

    create_resources(systemd::timer::job, $timer, $timer_defaults)

}