Puppet Class: bgpalerter

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

Overview

SPDX-License-Identifier: Apache-2.0

Parameters:

  • monitors (Array[Bgpalerter::Monitor])

    array of monitors to configure

  • reports (Array[Bgpalerter::Report])

    array of reports to configure

  • prefixes (Hash[Stdlib::IP::Address, Bgpalerter::Prefix]) (defaults to: {})

    The prefixes to monitor. use ./bgpalerter-linux-x64 generate -a $AS -o prefixes.yaml to generate

  • prefixe_options

    The prefix options. use the genrate command above to create config

  • notification_interval_seconds

    Defines the amount of seconds after which an alert can be repeated.

  • persist_status

    Persist the status of BGPalerter. If the process is restarted, the list of alerts already sent is recovered

  • logging (Bgpalerter::Logging)
  • rpki (Bgpalerter::Rpki)
  • rest (Bgpalerter::Rest)
  • manage_user (Boolean) (defaults to: false)
  • user (String) (defaults to: 'bgpalerter')
  • notificationIntervalSeconds (Integer) (defaults to: 86400)
  • persistStatus (Boolean) (defaults to: true)
  • checkForUpdatesAtBoot (Boolean) (defaults to: true)
  • generatePrefixListEveryDays (Integer) (defaults to: 0)
  • httpProxy (Optional[Stdlib::HTTPUrl]) (defaults to: undef)
  • prefixes_options (Optional[Bgpalerter::Prefix::Options]) (defaults to: undef)


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
# File 'modules/bgpalerter/manifests/init.pp', line 12

class bgpalerter (
    # defaults loaded from data/common.yaml
    Bgpalerter::Logging        $logging,
    Bgpalerter::Rpki           $rpki,
    Bgpalerter::Rest           $rest,
    Array[Bgpalerter::Report]  $reports,
    Array[Bgpalerter::Monitor] $monitors,

    Boolean                    $manage_user                         = false,
    String                     $user                                = 'bgpalerter',
    # ignore camel case as that's what the app uses
    # lint:ignore:variable_is_lowercase
    Integer                    $notificationIntervalSeconds         = 86400,
    Boolean                    $persistStatus                       = true,
    Boolean                    $checkForUpdatesAtBoot               = true,
    Integer                    $generatePrefixListEveryDays         = 0,
    Optional[Stdlib::HTTPUrl]  $httpProxy                           = undef,
    # lint:endignore
    Optional[Bgpalerter::Prefix::Options]         $prefixes_options = undef,
    Hash[Stdlib::IP::Address, Bgpalerter::Prefix] $prefixes         = {},
) {
    $base_dir = '/etc/bgpalerter'
    $working_dir = '/run/bgpalerter'
    $bgpalerter_bin = '/usr/local/bin/bgpalerter'
    $config_file = "${base_dir}/config.yaml"
    $prefix_file = "${base_dir}/prefixes.yaml"
    $log_dir = $logging['directory'] ? {
        Stdlib::Unixpath => $logging['directory'],
        default          => "${base_dir}/${logging['directory']}"
    }
    # list of params which are not config keys
    # hard code this as there is only one set of options that make senses
    $ris_connector = {
        'file'   => 'connectorRIS',
        'name'   => 'ris',
        'params' => {
            'carefulSubscription' => true,
            'url'                 => 'ws://ris-live.ripe.net/v1/ws/',
            'perMessageDeflate'   => true,
            'subscriptions'       => {
                'moreSpecific'  => true,
                'type'          => 'UPDATE',
                'host'          => undef,  # This seems empty in the generate config?
                'socketOptions' => {'includeRaw' => false},
            }
        }
    }
    $filter_params = ['name', 'user', 'manage_user', 'prefixes', 'prefixes_options']
    $config = wmflib::dump_params($filter_params) + {
        'connectors'                => [$ris_connector],
        'monitoredPrefixesFiles'    => [$prefix_file],
        # Advanced settings (Don't touch here!)
        'alertOnlyOnce'             => false,
        'fadeOffSeconds'            => 360,
        'checkFadeOffGroupsSeconds' => 30,
        'pidFile'                   => 'bgpalerter.pid',
        'maxMessagesPerSecond'      => 6000,
        'multiProcess'              => false,
        'environment'               => 'production',
        'configVersion'             => 2,
    }
    # TODO: install bgpalerter
    if $manage_user {
        user { $user:
            system => true,
            shell  => '/usr/sbin/nologin',
            home   => '/nonexistent',
        }
    }
    file { $base_dir:
        ensure => directory,
    }
    file { $log_dir:
        ensure => directory,
        owner  => $user,
        mode   => '0755'
    }
    file { $working_dir:
        ensure => directory,
        owner  => $user,
        mode   => '0750'
    }
    file { $config_file:
        ensure  => file,
        mode    => '0444',
        content => $config.to_yaml,
    }
    $_prefixes = prefixes_options ? {
        undef   => $prefixes,
        default => $prefixes + {'options' => $prefixes_options},
    }
    file { $prefix_file:
        ensure  => file,
        mode    => '0444',
        content => $_prefixes.to_yaml,
    }
    systemd::service { 'bgpalerter':
        content   => template('bgpalerter/bgpalerter.service.erb'),
        subscribe => File["${base_dir}/config.yaml", "${base_dir}/prefixes.yaml"],
    }
}