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,4 @@
---
- name: reload systemd
systemd:
daemon_reload: yes

View File

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

View File

@@ -0,0 +1,35 @@
#!/bin/bash
set -e
LAB_NAME="{{ gateway_config.lab_name }}"
VNI="{{ gateway_config.vni }}"
WG_IF="wg-${LAB_NAME}"
VXLAN_IF="vxlan${VNI}"
# Wait for WireGuard interface
timeout=30
while [ $timeout -gt 0 ]; do
if ip link show ${WG_IF} &>/dev/null; then
break
fi
sleep 1
((timeout--))
done
# Create VXLAN interface
if ! ip link show ${VXLAN_IF} &>/dev/null; then
ip link add ${VXLAN_IF} type vxlan \
id ${VNI} \
dev ${WG_IF} \
dstport {{ vxlan_port }} \
nolearning \
proxy
fi
# Configure VXLAN peers (FDB entries)
{% for peer in gateway_config.peers %}
bridge fdb append 00:00:00:00:00:00 dev ${VXLAN_IF} dst {{ peer.wg_ip }}
{% endfor %}
# Bring up interface
ip link set ${VXLAN_IF} up

View File

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