Skip to content

Commit e590ac2

Browse files
authored
Create multiple supernodes (#35)
1 parent 2d5c6a4 commit e590ac2

File tree

20 files changed

+268
-106
lines changed

20 files changed

+268
-106
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,8 @@
1010
- each supernode gets one IP from this prefix
1111
- Assign a management IP from the site management net
1212
- Statically set on the VM config
13+
14+
## Running Ansible
15+
16+
- Set `NETBOX_TOKEN` to your token
17+
- Run `ansible-playbook site.yml --diff --check`

ansible.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ pipelining = true
66
timeout = 15
77
roles_path = roles
88
remote_user = admin
9+
host_key_checking = False
910

1011
[ssh_connection]
1112
scp_if_ssh = true

group_vars/all.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,18 @@ gateway_ipv6_address: >-
2626
first
2727
}}
2828
29+
client_ipv4_start_address_int: "{{ gateway_ipv4_address | ansible.utils.ipaddr('network') | ansible.utils.ipaddr('int') }}"
30+
dhcp_range_start_address_int: "{{ (config_context|first).dhcp_range.start_address|ansible.utils.ipaddr('int') }}"
31+
dhcp_range_end_address_int: "{{ (config_context|first).dhcp_range.end_address|ansible.utils.ipaddr('int') }}"
32+
dhcp_pool_offset: "{{ (dhcp_range_start_address_int|int) - (client_ipv4_start_address_int|int) - 1 }}"
33+
dhcp_pool_size: "{{ (dhcp_range_end_address_int|int) - (dhcp_range_start_address_int|int) }}"
34+
35+
# Private Anycast Address in the domain used for reaching DHCP & DNS
36+
# todo: replace with data from netbox
37+
anycast_service_address: "{{ gateway_ipv4_address | ansible.utils.ipaddr('network/prefix') | ansible.utils.ipaddr('-2') }}"
38+
2939
wan_interface: "{{ interfaces | selectattr('name', 'equalto', 'eth0') | first }}"
40+
# Outside IP used for connecting to the supernode from the Internet
3041
service_ipv4_address: >-
3142
{{ wan_interface.ip_addresses |
3243
map(attribute='address') |
@@ -39,3 +50,5 @@ loopback_interface: "{{ interfaces | selectattr('name', 'equalto', 'lo') | first
3950
service_ipv6_address: "{{ gateway_ipv6_address }}"
4051

4152
domain_ipv6_subnet: "{{ gateway_ipv6_address | ansible.utils.ipaddr('network/prefix') }}"
53+
54+
batbone_interface: "{{ interfaces | selectattr('name', 'equalto', 'eth1') | first }}"

roles/batman/tasks/main.yaml

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,15 @@
1515
line: batman-adv
1616
create: true
1717

18-
- name: Create Batman Interface
18+
- name: Configure Networking
1919
ansible.builtin.template:
20-
src: batman.netdev.j2
21-
dest: /etc/systemd/network/batman.netdev
22-
notify: reload network
23-
24-
- name: Configure Batman Interface
25-
ansible.builtin.template:
26-
src: batman.network.j2
27-
dest: /etc/systemd/network/batman.network
28-
notify: reload network
29-
30-
- name: Create Batman Bridge
31-
ansible.builtin.template:
32-
src: batman-bridge.netdev.j2
33-
dest: /etc/systemd/network/batman-bridge.netdev
34-
notify: reload network
35-
36-
- name: Configure Batman Bridge
37-
ansible.builtin.template:
38-
src: batman-bridge.network.j2
39-
dest: /etc/systemd/network/batman-bridge.network
20+
src: "{{ item }}.j2"
21+
dest: "/etc/systemd/network/{{ item }}"
22+
loop:
23+
- batman.netdev
24+
- batman.network
25+
- batman-bridge.netdev
26+
- batman-bridge.network
27+
- batbone.link
28+
- batbone.network
4029
notify: reload network
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[Match]
2+
MACAddress={{ (batbone_interface.mac_addresses | first).mac_address }}
3+
4+
[Link]
5+
Name=eth1
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[Match]
2+
MACAddress={{ (batbone_interface.mac_addresses | first).mac_address }}
3+
4+
[Link]
5+
RequiredForOnline=no
6+
7+
[Network]
8+
Bridge=br1

roles/gateway/templates/client-bridge.network.j2

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ DHCPServer=yes
1212
IPv6SendRA=yes
1313

1414
[DHCPServer]
15-
PoolOffset=10
16-
PoolSize=64000
15+
PoolOffset={{ dhcp_pool_offset }}
16+
PoolSize={{ dhcp_pool_size }}
1717
EmitDNS=yes
18-
ServerAddress=10.12.255.254/16
19-
DNS={{ service_ipv4_address | ansible.utils.ipaddr('address') }}
18+
ServerAddress={{ anycast_service_address }}
19+
DNS={{ anycast_service_address | ansible.utils.ipaddr('address') }}
2020

2121
{% for addr in client_bridge_interface.ip_addresses | map(attribute='address') | ansible.utils.ipv6 %}
2222
[IPv6Prefix]

roles/gateway/templates/dnsmasq.conf.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
interface=br0
22
except-interface=lo
3-
listen-address={{ gateway_ipv4_address | ansible.utils.ipaddr('address') }}
3+
listen-address={{ anycast_service_address | ansible.utils.ipaddr('address') }}
44
listen-address={{ gateway_ipv6_address | ansible.utils.ipaddr('address') }}
55
bind-interfaces
66

terraform/.terraform.lock.hcl

Lines changed: 41 additions & 41 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

terraform/batbone.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
resource "netbox_available_vlan" "batbone" {
2+
name = "batbone ${var.domain_name}"
3+
status = "active"
4+
description = "Batbone VLAN for ${var.domain_name}"
5+
6+
group_id = var.batbone_vlan_group_id
7+
site_id = data.netbox_site.local.id
8+
}

0 commit comments

Comments
 (0)