Puppet Class: profile::bird::anycast

Defined in:
modules/profile/manifests/bird/anycast.pp

Overview

Parameters:

  • bfd (Boolean) (defaults to: lookup('profile::bird::bfd', {'default_value' => true}))
  • neighbors_list (Optional[Array[Stdlib::IP::Address::Nosubnet]]) (defaults to: lookup('profile::bird::neighbors_list', {default_value => undef}))
  • bind_anycast_service (Optional[String]) (defaults to: lookup('profile::bird::bind_anycast_service', {'default_value' => undef}))
  • advertise_vips (Optional[Hash[String, Wmflib::Advertise_vip]]) (defaults to: lookup('profile::bird::advertise_vips', {'default_value' => {}}))
  • prometheus_nodes (Optional[Array[Stdlib::Fqdn]]) (defaults to: lookup('prometheus_nodes', {'default_value' => undef}))
  • do_ipv6 (Optional[Boolean]) (defaults to: lookup('profile::bird::do_ipv6', {'default_value' => false}))
  • anycasthc_logging (Optional[Bird::Anycasthc_logging]) (defaults to: lookup('profile::bird::anycasthc_logging', {'default_value' => undef}))


8
9
10
11
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
113
114
115
116
117
118
119
120
121
# File 'modules/profile/manifests/bird/anycast.pp', line 8

class profile::bird::anycast(
  Boolean                                        $bfd                  = lookup('profile::bird::bfd', {'default_value' => true}),
  Optional[Array[Stdlib::IP::Address::Nosubnet]] $neighbors_list       = lookup('profile::bird::neighbors_list', {default_value => undef}),
  Optional[String]                               $bind_anycast_service = lookup('profile::bird::bind_anycast_service', {'default_value' => undef}),
  Optional[Hash[String, Wmflib::Advertise_vip]]  $advertise_vips       = lookup('profile::bird::advertise_vips', {'default_value' => {}}),
  Optional[Array[Stdlib::Fqdn]]                  $prometheus_nodes     = lookup('prometheus_nodes', {'default_value' => undef}),
  Optional[Boolean]                              $do_ipv6              = lookup('profile::bird::do_ipv6', {'default_value' => false}),
  Optional[Bird::Anycasthc_logging]              $anycasthc_logging    = lookup('profile::bird::anycasthc_logging', {'default_value' => undef}),
){

  $advertise_vips.each |$vip_fqdn, $vip_params| {
    if $do_ipv6 and !$vip_params['address_ipv6'] {
      fail("IPv6 support was enabled but the IPv6 address for ${vip_fqdn} was not set.")
    }
  }

  if $neighbors_list {
    $_neighbors_list = $neighbors_list
  } else {
    $_neighbors_list = $do_ipv6 ? {
        true    => [$facts['default_routes']['ipv4'], $facts['default_routes']['ipv6']],
        default => [$facts['default_routes']['ipv4']],
    }
  }

  $neighbors_for_ferm = join($_neighbors_list, ' ')

  ferm::service { 'bird-bgp':
      proto  => 'tcp',
      port   => '179',
      srange => "(${neighbors_for_ferm})",
      before => Class['::bird'],
  }

  # Ports from https://github.com/BIRD/bird/blob/master/proto/bfd/bfd.h#L28-L30
  if $bfd {
    ferm::service { 'bird-bfd-control':
        proto  => 'udp',
        port   => '3784',
        srange => "(${neighbors_for_ferm})",
        before => Class['::bird'],
    }
    ferm::service { 'bird-bfd-echo':
        proto  => 'udp',
        port   => '3785',
        srange => "(${neighbors_for_ferm})",
        before => Class['::bird'],
    }
    ferm::service { 'bird-bfd-multi-ctl':  # Multihop BFD
        proto  => 'udp',
        port   => '4784',
        srange => "(${neighbors_for_ferm})",
        before => Class['::bird'],
    }
  }

  if $prometheus_nodes {
      $prometheus_nodes_ferm = join($prometheus_nodes, ' ')
      ferm::service { 'bird-prometheus-acl':
          desc   => 'Bird prometheus port',
          proto  => 'tcp',
          port   => '9324',
          srange => "(@resolve((${prometheus_nodes_ferm})) @resolve((${prometheus_nodes_ferm}), AAAA))",
      }
  }

  class { '::bird::anycast_healthchecker':
      bind_service => $bind_anycast_service,
      do_ipv6      => $do_ipv6,
      logging      => $anycasthc_logging,
  }

  require ::profile::bird::anycast_healthchecker_monitoring

  class { '::bird':
      neighbors    => $_neighbors_list,
      bind_service => 'anycast-healthchecker.service',
      bfd          => $bfd,
      do_ipv6      => $do_ipv6,
      require      => Class['::bird::anycast_healthchecker'],
  }

  $advertise_vips.each |$vip_fqdn, $vip_params| {
    interface::ip { "lo-vip-${vip_fqdn}":
      ensure    => $vip_params['ensure'],
      address   => $vip_params['address'],
      interface => 'lo',
      options   => 'label lo:anycast',
      before    => Class['::bird']
    }
    bird::anycast_healthchecker_check { "hc-vip-${vip_fqdn}":
      ensure         => $vip_params['ensure'],
      address        => $vip_params['address'],
      check_cmd      => $vip_params['check_cmd'],
      check_fail     => $vip_params['check_fail'],
      do_ipv6        => $do_ipv6,
      address_ipv6   => $vip_params['address_ipv6'],
      check_cmd_ipv6 => $vip_params['check_cmd_ipv6'],
    }
    if $do_ipv6 {
      interface::ip { "lo-vip-${vip_fqdn}-ipv6":
        ensure    => $vip_params['ensure'],
        address   => $vip_params['address_ipv6'],
        prefixlen => '128',
        interface => 'lo',
        options   => 'label lo:anycast',
        before    => Class['::bird']
      }
    }
  }
  profile::contact { $title:
      contacts => ['ayounsi']
  }
}