Automatically create wireguard and ibgp mesh between nodes #1

Merged
mans merged 3 commits from new-automation into main 2025-11-09 13:31:40 +00:00
9 changed files with 185 additions and 78 deletions
Showing only changes of commit 4a003c36c9 - Show all commits

View File

@@ -15,27 +15,33 @@ ospf:
- "2a02:898:424::/48+" # ColoClue space
routers:
"rtr1.nlams1":
"rtr1nlams1":
fqdn: rtr1.nlams1.as205079.net
ipv4: 94.142.240.55
ipv6: 2001:678:10ec:2201::1
gre_mtu: 1476
gre_ll: "fe80::2050:79:2"
site_name: "NLAMS1"
site_id: 2
graceful_shutdown: false
maintenance_mode: false
"rtr1.nlape1":
"rtr1nlape1":
fqdn: rtr1.nlape1.as205079.net
ipv4: 194.28.98.155
ipv6: 2001:678:10ec:3201::1
gre_mtu: 1476
gre_ll: "fe80::2050:79:3"
site_name: "NLAPE1"
site_id: 3
graceful_shutdown: false
maintenance_mode: false
"rtr1.nlwie1":
"rtr1nlwie1":
fqdn: rtr1.nlwie1.as205079.net
pub_ipv4: 86.94.191.237
ipv4: 10.20.10.23 # router is behind NAT
ipv6: 2001:678:10ec:1201::1
gre_mtu: 1468
gre_ll: "fe80::2050:79:1"
site_name: "NLWIE1"
site_id: 1
graceful_shutdown: false

View File

@@ -1,6 +1,4 @@
location:
code: "NLAMS1"
site_id: "2"
shortname: rtr1nlams1
ipv6:
primary: "2001:0678:10ec:2201::1"
@@ -18,29 +16,27 @@ routes:
- "2001:678:10ec::/48" # My space
- "2a02:898:424::/48" # ColoClue space
# dummy_interfaces: {}
gre:
tunnels:
- name: "INT-RTR1NLAPE1"
remote_endpoint: 194.28.98.155
local_endpoint: 94.142.240.55
local_ipv6: 2001:678:10ec:20e::1/64
ttl: 255
mtu: 1476
- name: "INT-RTR1NLWIE1"
remote_endpoint: 86.94.191.237
local_endpoint: 94.142.240.55
local_ipv6: 2001:678:10ec:20d::1/64
ttl: 255
mtu: 1468
# gre:
# tunnels:
# - name: "INT-RTR1NLAPE1"
# remote_endpoint: 194.28.98.155
# local_endpoint: 94.142.240.55
# local_ipv6: 2001:678:10ec:20e::1/64
# ttl: 255
# mtu: 1476
# - name: "INT-RTR1NLWIE1"
# remote_endpoint: 86.94.191.237
# local_endpoint: 94.142.240.55
# local_ipv6: 2001:678:10ec:20d::1/64
# ttl: 255
# mtu: 1468
interfaces:
- nic: "loop0"
description: "Loopback interface"
stub: true
- nic: "INT-RTR1NLAPE1"
- nic: "INT-RTR1NLWIE1"
- nic: "int-rtr1nlape1"
- nic: "int-rtr1nlwie1"
- nic: "vmbr1"
description: "NLAMS1 Servers"
stub: true
@@ -72,8 +68,6 @@ peers:
import: "RIPE::AS212855:AS-LUJE"
export: "RIPE::AS205079:AS-MANS"
peer_ipv6: "2a02:898:0:20::427:1"
internal_peers:
- name: "RTR1APE1"
ip: "2001:678:10ec:3201::1"

View File

@@ -1,6 +1,4 @@
location:
code: "NLAPE1"
site_id: "3"
shortname: rtr1nlape1
ipv6:
primary: "2001:0678:10ec:3201::1"
@@ -15,18 +13,18 @@ routes:
gre:
tunnels:
- name: "INT-RTR1NLWIE1"
remote_endpoint: 86.94.191.237
local_endpoint: 194.28.98.155
local_ipv6: 2001:678:10ec:20f:0:0:0:1/112
ttl: 255
mtu: 1468
- name: "INT-RTR1NLAMS1"
remote_endpoint: 94.142.240.55
local_endpoint: 194.28.98.155
local_ipv6: 2001:678:10ec:20e::2/64
ttl: 255
mtu: 1476
# - name: "INT-RTR1NLWIE1"
# remote_endpoint: 86.94.191.237
# local_endpoint: 194.28.98.155
# local_ipv6: 2001:678:10ec:20f:0:0:0:1/112
# ttl: 255
# mtu: 1468
# - name: "INT-RTR1NLAMS1"
# remote_endpoint: 94.142.240.55
# local_endpoint: 194.28.98.155
# local_ipv6: 2001:678:10ec:20e::2/64
# ttl: 255
# mtu: 1476
- name: "ROUTE64-AMS1"
remote_endpoint: 118.91.187.67
local_endpoint: 194.28.98.155
@@ -92,8 +90,8 @@ interfaces:
- nic: "ens19"
description: "To Loc-IX"
stub: true
- nic: "INT-RTR1NLWIE1"
- nic: "INT-RTR1NLAMS1"
- nic: "int-rtr1nlwie1"
- nic: "int-rtr1nlams1"
rpki:
run_routinator: true

View File

@@ -1,6 +1,4 @@
location:
code: "NLWIE1"
site_id: "1"
shortname: rtr1nlwie1
ipv6:
primary: "2001:0678:10ec:1201::1"
@@ -13,20 +11,20 @@ routes:
6:
- "2001:678:10ec::/48"
gre:
tunnels:
- name: "INT-RTR1NLAPE1"
remote_endpoint: 194.28.98.155
local_endpoint: 10.20.10.23
local_ipv6: 2001:678:10ec:20f:0:0:0:2/112
ttl: 255
mtu: 1468
- name: "INT-RTR1NLAMS1"
remote_endpoint: 94.142.240.55
local_endpoint: 10.20.10.23
local_ipv6: 2001:678:10ec:20d::2/64
ttl: 255
mtu: 1468
# gre:
# tunnels:
# - name: "INT-RTR1NLAPE1"
# remote_endpoint: 194.28.98.155
# local_endpoint: 10.20.10.23
# local_ipv6: 2001:678:10ec:20f:0:0:0:2/112
# ttl: 255
# mtu: 1468
# - name: "INT-RTR1NLAMS1"
# remote_endpoint: 94.142.240.55
# local_endpoint: 10.20.10.23
# local_ipv6: 2001:678:10ec:20d::2/64
# ttl: 255
# mtu: 1468
interfaces:
- nic: "loop0"
@@ -37,8 +35,8 @@ interfaces:
- nic: "eth1"
description: "nlwie1 servers"
stub: true
- nic: "INT-RTR1NLAPE1"
- nic: "INT-RTR1NLAMS1"
- nic: "int-rtr1nlape1"
- nic: "int-rtr1nlams1"
- nic: "wg0"
description: "wireguard remote"
stub: true

View File

@@ -7,7 +7,7 @@
roles:
# - base
# - sysctl
- dummy-interfaces
# - dummy-interfaces
- gre
# - routinator
- bird2

View File

@@ -3,8 +3,3 @@
cmd: "ifreload -a"
register: ifreload_result
changed_when: ifreload_result.stdout != "" and "Reloading" in ifreload_result.stdout
- name: "Restart networking"
ansible.builtin.systemd:
name: networking
state: restarted

View File

@@ -1,4 +1,12 @@
- name: "Ensure gre interfaces are present"
- name: "Ensure internal gre interfaces are present"
ansible.builtin.template:
src: internal_gre_interfaces.j2
dest: /etc/network/interfaces.d/internal_gre_interfaces
mode: "0644"
notify:
- "Reload networking"
- name: "Ensure extra gre interfaces are present"
ansible.builtin.template:
src: gre_interface.j2
dest: /etc/network/interfaces.d/{{ item.name }}

View File

@@ -0,0 +1,11 @@
{%- for router in routers if not router == shortname %}
auto int-{{ router }}
iface int-{{ router }} inet6 static
pre-up ip tunnel add int-{{ router }} mode gre remote {{ routers[router]['pub_ipv4'] | default(routers[router]['ipv4']) }} local {{ routers[shortname]['ipv4'] }} ttl 255
pre-up ip addr add {{ routers[shortname]['gre_ll'] }}/64 dev int-{{ router }}
up ip link set dev int-{{ router }} up
# up ip link set int-{{ router }} mtu {{ routers[router]['gre_mtu'] }}
up ip link set dev int-{{ router }} mtu 1468
post-down ip tunnel del int-{{ router }}
{% endfor %}