Files
puppet-prod/modules/frrouting/manifests/init.pp
T
unkin-agent 015a516f54
ci/woodpecker/pr/bolt-validate Pipeline was successful
ci/woodpecker/pr/erb-validate Pipeline was successful
ci/woodpecker/pr/ruby-validate Pipeline was successful
ci/woodpecker/pr/puppet-lint Pipeline was successful
ci/woodpecker/pr/yamllint Pipeline was successful
ci/woodpecker/pr/epp-validate Pipeline was successful
ci/woodpecker/pr/puppet-validate Pipeline was successful
ci/woodpecker/pr/ruby-check Pipeline was successful
Set wgvpn keys and resolve the vpc ospf interface from its subnet
2026-10-17 12:51:02 +11:00

125 lines
4.1 KiB
Puppet

class frrouting (
Boolean $manage_package = true,
Boolean $manage_config = true,
Boolean $manage_service = true,
String $package_name = 'frr',
String $service_name = 'frr',
Hash $daemons = {},
Hash $ospfd_interfaces = {},
Hash[Stdlib::IP::Address::V4::CIDR, Hash] $ospfd_network_interfaces = {}, # like ospfd_interfaces, keyed by a subnet the interface holds
String $ospfd_router_id = $facts['networking']['ip'],
Array[String] $ospfd_redistribute = [],
Array[String] $ospfd_networks = [],
Boolean $ospfd_default_originate_always = false,
Array[Stdlib::IP::Address::V4::CIDR] $ospfd_redistribute_connected_permit = [], # only these exact connected prefixes are redistributed
Boolean $ospfd_deny_default_in = false, # keep a learned default route out of the routing table
Boolean $mpls_te_enabled = false,
Optional[String] $mpls_ldp_router_id = undef,
Optional[String] $mpls_ldp_transport_addr = undef,
Array[String] $mpls_ldp_interfaces = [],
Boolean $ospf_preferred_source_enable = false,
Optional[Stdlib::IP::Address] $ospf_preferred_source = undef,
Boolean $ospf_exclude_k8s_enable = false,
Optional[Stdlib::IP::Address::V4::CIDR] $k8s_cluster_cidr = undef, # pod/cluster CIDR (e.g. 10.42.0.0/16)
Optional[Stdlib::IP::Address::V4::CIDR] $k8s_service_cidr = undef, # service CIDR (e.g. 10.43.0.0/16)
) {
# sanity check
if $ospf_exclude_k8s_enable and $k8s_cluster_cidr == undef and $k8s_service_cidr == undef {
warning('frrouting: ospf_exclude_k8s_enable is true but no k8s_*_cidr provided; nothing will be filtered.')
}
$network_interfaces = $ospfd_network_interfaces.reduce({}) |$memo, $entry| {
$matched = $facts['networking']['interfaces'].filter |$name, $iface| {
$iface['bindings'] =~ Array and $iface['bindings'].any |$binding| { stdlib::ip_in_range($binding['address'], $entry[0]) }
}
if empty($matched) {
fail("frrouting: no interface holds an address in ${entry[0]}")
}
$memo + $matched.keys.reduce({}) |$acc, $name| { $acc + { $name => $entry[1] } }
}
$ospfd_interfaces_all = $ospfd_interfaces + $network_interfaces
$daemons_defaults = {
'bgpd' => false,
'ospfd' => true,
'ospf6d' => false,
'ldpd' => false,
'ripd' => false,
'ripngd' => false,
'isisd' => false,
'pimd' => false,
'pim6d' => false,
'nhrpd' => false,
'eigrpd' => false,
'sharpd' => false,
'pbrd' => false,
'bfdd' => false,
'fabricd' => false,
'vrrpd' => false,
'pathd' => false,
'staticd' => false,
}
$daemons_merged = merge($daemons_defaults, $daemons)
if $manage_package {
package { $package_name:
ensure => installed,
}
}
if $manage_config {
file { '/etc/frr/frr.conf':
ensure => file,
content => template('frrouting/frr.conf.erb'),
notify => Service[$service_name],
}
file { '/etc/frr/daemons':
ensure => file,
content => template('frrouting/daemons.erb'),
notify => Service[$service_name],
}
}
if $facts['os']['release']['major'] == '8' {
systemd::manage_dropin { 'default_nice_level.conf':
ensure => present,
unit => 'frr.service',
service_entry => {
'Nice' => 0,
},
notify => Service['frr'],
}
}
if $manage_service {
service { $service_name:
ensure => running,
enable => true,
hasstatus => true,
hasrestart => true,
}
}
if $mpls_ldp_router_id and $mpls_ldp_transport_addr and !empty($mpls_ldp_interfaces) {
file { '/etc/modules-load.d/mpls_ldp_modules.conf':
ensure => file,
content => @(EOT/L),
# Load MPLS Kernel Modules
mpls_router
mpls_iptunnel
| EOT
}
['mpls_router', 'mpls_iptunnel'].each |$mod| {
exec { "load_${mod}":
command => "/sbin/modprobe ${mod}",
unless => "/sbin/lsmod | /bin/grep -q ^${mod}",
path => ['/sbin', '/bin', '/usr/sbin', '/usr/bin'],
}
}
}
}