Puppet Class: bgpalerter

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

Summary

imanage BGPalerter

Overview

SPDX-License-Identifier: Apache-2.0

Parameters:

  • logging (Bgpalerter::Logging)

    logging configuration

  • rpki (Bgpalerter::Rpki)

    rpki configuration

  • rest (Bgpalerter::Rest)

    REST configuration

  • monitors (Array[Bgpalerter::Monitor])

    array of monitors to configure

  • reports (Array[Bgpalerter::Report])

    array of reports to configure

  • persist_status

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

  • notification_interval_seconds

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

  • check_for_updates_at_boot

    Indicates if at each booth the application should check for updates

  • generate_prefix_list_every_days

    This parameter allows to automatically re-generate the prefix list after the specified amount of days. Set to 0 to disable it.

  • manage_user (Boolean) (defaults to: false)

    indicate if we should manage the daemon user

  • user (String) (defaults to: 'bgpalerter')

    the damoen user

  • http_proxy

    optional http proxy server to use

  • 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

  • prefixes_options (Optional[Bgpalerter::Prefix::Options]) (defaults to: undef)

    The prefix options. use the genrate command above to create config already sent is recovered

  • 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)


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

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         = {},
) {
    ensure_packages('node-bgpalerter')
    $base_dir = '/etc/bgpalerter'
    $working_dir = '/run/bgpalerter'
    $bgpalerter_bin = '/usr/bin/bgpalerter'
    $config_file = "${base_dir}/config.yml"
    $prefix_file = "${base_dir}/prefixes.yml"
    $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' => {
            'authorizationHeader' => undef,
            'carefulSubscription' => true,
            'url'                 => 'wss://ris-live.ripe.net/v1/ws/',
            'perMessageDeflate'   => true,
            'subscription'        => {
                '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::resource::filter_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 {
        systemd::sysuser { 'bgpalerter': }
    }
    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,
    }
    service { 'node-bgpalerter':
        ensure    => 'running',
        enable    => true,
        subscribe => File[$config_file, $prefix_file],
    }

    profile::auto_restarts::service { 'node-bgpalerter':}
}