Puppet Class: bgpalerter
- Defined in:
- modules/bgpalerter/manifests/init.pp
Overview
SPDX-License-Identifier: Apache-2.0
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"],
}
}
|