Puppet Class: profile::librenms

Defined in:
modules/profile/manifests/librenms.pp

Overview

$active_server Which of the netmon servers should actually poll data and have active cron jobs. We don't want both to do it at the same time. Switch it in hieradata/common.yaml, the default is just a fallback.

Parameters:

  • active_server (Stdlib::Fqdn) (defaults to: lookup('netmon_server'))
  • passive_server (Stdlib::Fqdn) (defaults to: lookup('netmon_server_failover'))
  • graphite_host (Stdlib::Fqdn) (defaults to: lookup('graphite_host'))
  • graphite_prefix (String) (defaults to: lookup('profile::librenms::graphite_prefix'))
  • sitename (String) (defaults to: lookup('profile::librenms::sitename'))
  • install_dir (Stdlib::Unixpath) (defaults to: lookup('profile::librenms::install_dir'))
  • laravel_app_key (String) (defaults to: lookup('profile::librenms::laravel_app_key'))
  • db_user (String) (defaults to: lookup('profile::librenms::dbuser'))
  • db_password (String) (defaults to: lookup('profile::librenms::dbpassword'))
  • db_host (Stdlib::Fqdn) (defaults to: lookup('profile::librenms::dbhost'))
  • db_name (String) (defaults to: lookup('profile::librenms::dbname'))
  • irc_password (String) (defaults to: lookup('profile::librenms::irc_password'))
  • ldap_config (Hash) (defaults to: lookup('ldap', Hash, hash, {}))
  • auth_mechanism (Enum['ldap','sso']) (defaults to: lookup('profile::librenms::auth_mechanism'))


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
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# File 'modules/profile/manifests/librenms.pp', line 8

class profile::librenms (
    Stdlib::Fqdn       $active_server   = lookup('netmon_server'),
    Stdlib::Fqdn       $passive_server  = lookup('netmon_server_failover'),
    Stdlib::Fqdn       $graphite_host   = lookup('graphite_host'),
    String             $graphite_prefix = lookup('profile::librenms::graphite_prefix'),
    String             $sitename        = lookup('profile::librenms::sitename'),
    Stdlib::Unixpath   $install_dir     = lookup('profile::librenms::install_dir'),
    String             $laravel_app_key = lookup('profile::librenms::laravel_app_key'),

    String             $db_user         = lookup('profile::librenms::dbuser'),
    String             $db_password     = lookup('profile::librenms::dbpassword'),
    Stdlib::Fqdn       $db_host         = lookup('profile::librenms::dbhost'),
    String             $db_name         = lookup('profile::librenms::dbname'),

    String             $irc_password    = lookup('profile::librenms::irc_password'),
    Hash               $ldap_config     = lookup('ldap', Hash, hash, {}),
    Enum['ldap','sso'] $auth_mechanism  = lookup('profile::librenms::auth_mechanism')
){

    include network::constants
    include passwords::network

    $config = {
        'title_image'      => '//upload.wikimedia.org/wikipedia/commons/thumb/0/0c/Wikimedia_Foundation_logo_-_horizontal_%282012-2016%29.svg/140px-Wikimedia_Foundation_logo_-_horizontal_%282012-2016%29.svg.png',

        # disable evil daily auto-git pull
        'update'           => 0,

        # Note that the DB settings will be copied in $install_dir/.env too
        'db_host'          => $db_host,
        'db_user'          => $db_user,
        'db_pass'          => $db_password,
        'db_name'          => $db_name,
        'db'               => {
            'extension' => 'mysqli',
        },

        # https://docs.librenms.org/Support/Cleanup-options/
        'device_perf_purge' => 30,
        'eventlog_purge'    => 360,
        'perf_times_purge'  => 90,
        'syslog_purge'      => 90,

        'snmp'             => {
            'community' => [ $passwords::network::snmp_ro_community ],
        },
        'irc_host'         => 'irc.freenode.org',
        'irc_chan'         => ['#wikimedia-operations'],
        'irc_alert'        => true,
        'irc_debug'        => false,
        'irc_alert_chan'   => '#wikimedia-operations',
        'irc_alert_utf8'   => true,
        'irc_alert_short'  => true,
        'irc_nick'         => 'librenms-wmf',
        'irc_pass'         => "librenms-wmf:${irc_password}",

        'autodiscovery'    => {
            'xdp'      => true,
            'ospf'     => true,
            'bgp'      => false,
            'snmpscan' => false,
        },
        'geoloc'             => {
            'latlng' => true,
            'engine' => 'google',
        },
        'location_map'       => {
            'eqiad' => 'Equinix, Ashburn, Virginia, USA',
            'codfw' => 'CyrusOne, Carrollton, Texas, USA',
            'eqdfw' => 'Equinix, Carrollton, Texas, USA',
            'ulsfo' => 'United Layer, San Francisco, California, USA',
            'eqord' => 'Equinix, Chicago, Illinois, USA',
            'knams' => 'Vancis, Amsterdam, The Netherlands',
            'esams' => 'EvoSwitch, Amsterdam, The Netherlands',
            'eqsin' => 'Equinix, Singapore',
        },
        'astext'       => {
            '64600' => 'PyBal',
            '64601' => 'Kubernetes',
            '64602' => 'Kubernetes',
            '64603' => 'Kubernetes',
            '64605' => 'Anycast',
            '64700' => 'frack-eqiad',
            '64701' => 'frack-codfw',
            '65001' => 'confed-eqiad-eqord',
            '65002' => 'confed-eqdfw-codfw',
            '65003' => 'confed-esams',
            '65004' => 'confed-ulsfo',
            '65005' => 'confed-eqsin',
            '65517' => 'Equinix',
        },
        'twofactor' => true,
        'twofactor_lock' => 300,
        'rancid_configs'         => ['/var/lib/rancid/core/configs/'],
        'rancid_ignorecomments'  => 1,
        'enable_inventory' => 1,
        'enable_syslog'    => 1,
        'enable_billing'   => 1,
        'syslog_filter'    => [
            'message repeated',
            'Connection from UDP: [',
            'CMD (   /usr/libexec/atrun)',
            'CMD (newsyslog)',
            'CMD (adjkerntz -a)',
            'kernel time sync enabled',
            'preauth',
        ],
        'auth_mechanism'     => $auth_mechanism,

        'graphite'   => {
            'enable' => true,
            'host'   => $graphite_host,
            'port'   => '2003',
            'prefix' => $graphite_prefix,
        },
    }

    $ldap = {
        'auth_ldap_server'   => "ldap://${ldap_config[ro-server]} ldap://${ldap_config[ro-server-fallback]}",
        'auth_ldap_starttls' => 'require',
        'auth_ldap_port'     => 389,

        # This is dumb -- the code requires us to specify the dn rather
        #  than doing a search, so logins will require 'shell name' rather
        #  than the more-traditional 'wikitech name'
        'auth_ldap_prefix'  => 'uid=',
        'auth_ldap_suffix'  => ',ou=people,dc=wikimedia,dc=org',
        'login_message'     => 'Log in with your ldap shell name (NOT the full name used on wikitech) and password.',

        # In our schema, a group is a list of user dns called 'member'
        'auth_ldap_groupbase' => 'ou=groups,dc=wikimedia,dc=org',
        'auth_ldap_groupmemberattr' => 'member',
        'auth_ldap_groupmembertype' => 'fulldn',

        # Give all ops full read/write permissions
        'auth_ldap_group'  => ['cn=ops,ou=groups,dc=wikimedia,dc=org', 'cn=librenms-readers,ou=groups,dc=wikimedia,dc=org'],
        'auth_ldap_groups' => {'ops' => {'level' => 10}, 'librenms-readers' => {'level' => 5}},
    }
    $sso = {
        'sso' => {
            'mode'            => 'env',
            'user_attr'       => 'HTTP_X_CAS_CN',
            'realname_attr'   => 'HTTP_CAS_USER',
            'email_attr'      => 'HTTP_X_CAS_MAIL',
            'create_users'    => true,
            'update_users'    => true,
            'group_strategy'  => 'map',
            'group_attr'      => 'HTTP_X_CAS_MEMBEROF',
            'group_level_map' => {
                'cn=ops' => 10,
                'cn=librenms-readers' => 5,
            },
            'group_delimiter' => ',',
        }
    }

    $_config = $auth_mechanism ? {
        'sso'   => $config + $sso,
        default => $config + $ldap,
    }
    class { 'librenms':
        install_dir     => $install_dir,
        rrd_dir         => '/srv/librenms/rrd',
        config          => $_config,
        active_server   => $active_server,
        laravel_app_key => $laravel_app_key,
    }
    class { 'librenms::syslog':
        require => Class['librenms']
    }

    include profile::librenms::web

    ferm::service { 'librenms-rsyslog':
        proto => 'udp',
        port  => '514',
    }

    ferm::service { 'librenms-http':
        proto => 'tcp',
        port  => '80',
    }

    ferm::service { 'librenms-https':
        proto => 'tcp',
        port  => '443',
    }

    backup::set {'librenms': }

    rsync::quickdatacopy { 'srv-librenms-rrd':
        ensure              => present,
        auto_sync           => false,
        source_host         => $active_server,
        dest_host           => $passive_server,
        module_path         => '/srv/librenms/rrd',
        server_uses_stunnel => true,
    }
}