From e2d550bf2996a00656990076eb748b4bb666e3e4 Mon Sep 17 00:00:00 2001 From: Patrik Lundin Date: Fri, 25 Oct 2024 15:19:21 +0200 Subject: [PATCH] Start managing bird2 Also give dummy-interface support to sunet-l4lb-namespace tool, used to hold IPv4/IPv6 service addresses that should be announced via BGP. --- .../cdn/files/l4lb/sunet-l4lb-namespace | 7 ++++++- .../etc/puppet/modules/cdn/manifests/l4lb.pp | 20 +++++++++++++++++++ .../cdn/templates/bird-override.conf.erb | 4 ++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 global/overlay/etc/puppet/modules/cdn/templates/bird-override.conf.erb diff --git a/global/overlay/etc/puppet/modules/cdn/files/l4lb/sunet-l4lb-namespace b/global/overlay/etc/puppet/modules/cdn/files/l4lb/sunet-l4lb-namespace index 3341838..39d86d0 100755 --- a/global/overlay/etc/puppet/modules/cdn/files/l4lb/sunet-l4lb-namespace +++ b/global/overlay/etc/puppet/modules/cdn/files/l4lb/sunet-l4lb-namespace @@ -47,7 +47,12 @@ def configure_interfaces( False, ) if not if_exists: - run_command(f"ip link set {if_name} netns {namespace}") + if if_name.startswith("dummy"): + run_command( + f"ip netns exec {namespace} ip link add {if_name} type dummy" + ) + else: + run_command(f"ip link set {if_name} netns {namespace}") proc = run_command(f"ip netns exec {namespace} ip -j addr show dev {if_name}") if_conf = json.loads(proc.stdout) diff --git a/global/overlay/etc/puppet/modules/cdn/manifests/l4lb.pp b/global/overlay/etc/puppet/modules/cdn/manifests/l4lb.pp index c75ecd9..17c2eca 100644 --- a/global/overlay/etc/puppet/modules/cdn/manifests/l4lb.pp +++ b/global/overlay/etc/puppet/modules/cdn/manifests/l4lb.pp @@ -15,6 +15,10 @@ class cdn::l4lb( } } + include sunet::systemd_reload + + package {'bird2': ensure => installed } + file { '/opt/sunet-cdn': ensure => directory, owner => 'root', @@ -59,4 +63,20 @@ class cdn::l4lb( mode => '0644', content => template('cdn/l4lb/sunet-l4lb-namespace.service.erb'), } + + file { '/etc/systemd/system/bird.service.d': + ensure => directory, + owner => 'root', + group => 'root', + mode => '0755', + } + + file { '/etc/systemd/system/bird.service.d/override.conf': + ensure => file, + owner => 'root', + group => 'root', + mode => '0644', + content => template('cdn/l4lb/bird-override.conf.erb'), + notify => [Class['sunet::systemd_reload']] + } } diff --git a/global/overlay/etc/puppet/modules/cdn/templates/bird-override.conf.erb b/global/overlay/etc/puppet/modules/cdn/templates/bird-override.conf.erb new file mode 100644 index 0000000..dcba5d8 --- /dev/null +++ b/global/overlay/etc/puppet/modules/cdn/templates/bird-override.conf.erb @@ -0,0 +1,4 @@ +[Service] +NetworkNamespacePath=/var/run/netns/l4lb +Wants=sunet-l4lb-namespace.service +After=sunet-l4lb-namespace.service