Puppet Class: bgpalerter
- Defined in:
- modules/bgpalerter/manifests/init.pp
Summary
imanage BGPalerterOverview
SPDX-License-Identifier: Apache-2.0
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':}
}
|