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
|
# File 'modules/bird/manifests/init.pp', line 29
class bird(
String $config_template = 'bird/bird_anycast.conf.erb',
Boolean $bfd = true,
Boolean $do_ipv6 = false,
Boolean $multihop = true,
Stdlib::IP::Address $ipv4_src = $facts['networking']['ip'],
Stdlib::IP::Address $ipv6_src = $facts['networking']['ip6'],
Optional[String] $bind_service = undef,
Optional[Array[Stdlib::IP::Address]] $neighbors = undef,
){
ensure_packages('bird2')
ensure_packages('prometheus-bird-exporter')
# Routed Ganeti
if $facts['networking']['netmask'] == '255.255.255.255' {
# Force BFD down as not support yet
$_bfd = false
$routed_ganeti = true
$v6_gateway = $facts['default_routes']['ipv6']
} else {
$_bfd = $bfd
$routed_ganeti = false
$v6_gateway = "${$facts['networking']['network6']}1"
}
if $neighbors {
$_neighbors_list = $neighbors
$_multihop = $multihop
} else {
$_neighbors_list = $do_ipv6 ? {
true => [$facts['default_routes']['ipv4'], $v6_gateway],
default => [$facts['default_routes']['ipv4']],
}
$_multihop = false
}
$neighbors_v4 = $_neighbors_list.filter |$neighbor| { $neighbor =~ Stdlib::IP::Address::V4::Nosubnet }
$neighbors_v6 = $_neighbors_list.filter |$neighbor| { $neighbor =~ Stdlib::IP::Address::V6::Nosubnet }
# In module as firewall always needs to be opened to BGP/BFD neighbors
# prevent code duplication in profiles
firewall::service { 'bird-bgp':
proto => 'tcp',
port => 179,
srange => $_neighbors_list,
}
# Ports from https://github.com/BIRD/bird/blob/master/proto/bfd/bfd.h#L28-L30
if $_bfd {
firewall::service { 'bird-bfd-control':
proto => 'udp',
port => 3784,
srange => $_neighbors_list,
src_sets => [ 'LINK_LOCAL' ],
}
firewall::service { 'bird-bfd-echo':
proto => 'udp',
port => 3785,
srange => $_neighbors_list,
src_sets => [ 'LINK_LOCAL' ],
}
if $_multihop {
firewall::service { 'bird-bfd-multi-ctl': # Multihop BFD
proto => 'udp',
port => 4784,
srange => $_neighbors_list,
}
}
}
systemd::service { 'bird':
ensure => present,
restart => true,
content => template('bird/bird.service.erb'),
require => [
Package['bird2'],
],
service_params => {
restart => 'systemctl reload bird.service',
},
}
file { '/etc/bird/bird.conf':
ensure => present,
owner => 'bird',
group => 'bird',
mode => '0640',
content => template($config_template),
notify => Systemd::Service['bird'],
require => Package['bird2'],
}
service { 'prometheus-bird-exporter':
ensure => running,
enable => true,
hasrestart => true,
require => Package['prometheus-bird-exporter'],
}
file { '/etc/default/prometheus-bird-exporter':
ensure => present,
owner => 'root',
group => 'root',
mode => '0444',
source => 'puppet:///modules/bird/prometheus-bird-exporter.default',
notify => Service['prometheus-bird-exporter'],
}
profile::auto_restarts::service { 'prometheus-bird-exporter': }
nrpe::monitor_service { 'bird':
ensure => present,
description => 'Bird Internet Routing Daemon',
nrpe_command => '/usr/lib/nagios/plugins/check_procs -c 1:1 -C bird',
notes_url => 'https://wikitech.wikimedia.org/wiki/Anycast#Bird_daemon_not_running',
migration_task => 'T357099',
}
}
|