Initial commit

This commit is contained in:
2026-02-21 16:54:18 +01:00
commit 0cf33cd95b
80 changed files with 8042 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
---
- name: Create bridge setup script
template:
src: setup-bridge.sh.j2
dest: /usr/local/bin/setup-bridge-{{ gateway_config.lab_name }}.sh
mode: '0755'
- name: Create systemd service for bridge
template:
src: bridge.service.j2
dest: /etc/systemd/system/bridge-{{ gateway_config.lab_name }}.service
notify: reload systemd
- name: Enable and start bridge service
systemd:
name: bridge-{{ gateway_config.lab_name }}
enabled: yes
state: started

View File

@@ -0,0 +1,13 @@
[Unit]
Description=Bridge for {{ gateway_config.lab_name }}
After=vxlan-{{ gateway_config.lab_name }}.service
Requires=vxlan-{{ gateway_config.lab_name }}.service
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/local/bin/setup-bridge-{{ gateway_config.lab_name }}.sh
ExecStop=/sbin/ip link delete br-{{ gateway_config.lab_name }}
[Install]
WantedBy=multi-user.target

View File

@@ -0,0 +1,38 @@
#!/bin/bash
set -e
LAB_NAME="{{ gateway_config.lab_name }}"
VNI="{{ gateway_config.vni }}"
BR_IF="br-${LAB_NAME}"
VXLAN_IF="vxlan${VNI}"
LAB_IF="{{ gateway_config.lab_if }}"
# Wait for VXLAN interface
timeout=30
while [ $timeout -gt 0 ]; do
if ip link show ${VXLAN_IF} >/dev/null 2>&1; then
break
fi
sleep 1
timeout=$((timeout-1))
done
# Create bridge
if ! ip link show ${BR_IF} &>/dev/null; then
ip link add ${BR_IF} type bridge
ip link set ${BR_IF} type bridge stp_state {{ bridge_stp | ternary('1', '0') }}
ip link set ${BR_IF} type bridge forward_delay {{ bridge_forward_delay }}
fi
# Add interfaces to bridge
ip link set ${VXLAN_IF} master ${BR_IF}
ip link set ${LAB_IF} master ${BR_IF}
# Configure bridge IP (for DHCP server)
ip addr flush dev ${BR_IF}
ip addr add {{ gateway_config.subnet | ipaddr('1') | ipaddr('address') }}/{{ gateway_config.subnet | ipaddr('prefix') }} dev ${BR_IF}
# Bring everything up
ip link set ${LAB_IF} up
ip link set ${VXLAN_IF} up
ip link set ${BR_IF} up