Puppet Class: bird

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

Overview

Parameters:

  • config_template (String) (defaults to: 'bird/bird_anycast.conf.erb')
  • bfd (Boolean) (defaults to: true)
  • do_ipv6 (Boolean) (defaults to: false)
  • multihop (Boolean) (defaults to: true)
  • ipv4_src (Stdlib::IP::Address) (defaults to: $facts['ipaddress'])
  • ipv6_src (Stdlib::IP::Address) (defaults to: $facts['ipaddress6'])
  • bind_service (Optional[String]) (defaults to: undef)
  • neighbors (Optional[Array[Stdlib::IP::Address]]) (defaults to: undef)


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

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['ipaddress'],
  Stdlib::IP::Address                  $ipv6_src        = $facts['ipaddress6'],
  Optional[String]                     $bind_service    = undef,
  Optional[Array[Stdlib::IP::Address]] $neighbors       = undef,
  ){

  ensure_packages(['bird2', 'prometheus-bird-exporter'])

  if $neighbors {
    $_neighbors_list = $neighbors
    $_multihop = $multihop
  } else {
    $_neighbors_list = $do_ipv6 ? {
        true    => [$facts['default_routes']['ipv4'], $facts['default_routes']['ipv6']],
        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,
    }
    firewall::service { 'bird-bfd-echo':
        proto  => 'udp',
        port   => 3785,
        srange => $_neighbors_list,
    }
    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'],
  }

  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',
  }
}