Add lg, adjust filters and inventory

This commit is contained in:
9pfs 2024-12-01 23:42:47 -08:00
parent db131bd02a
commit 58c2912f46
Signed by: 9pfs
SSH key fingerprint: SHA256:yVO09iotyiNaBzBBvVR8ZTx7SB9VpvJPgR1Ihy1bz3Q
7 changed files with 107 additions and 2 deletions

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
.*.swp .*.swp
bin/ bin/
src/

View file

@ -2,8 +2,14 @@
# "direct" protocol to read prefixes attached to interfaces and send them across # "direct" protocol to read prefixes attached to interfaces and send them across
# the network. # the network.
protocol direct { protocol direct {
ipv4; ipv4 {
ipv6; import where net ~ [ 172.20.0.0/16+, 172.31.0.0/16+, 10.0.0.0/8+ ];
export where net ~ [ 172.20.0.0/16+, 172.31.0.0/16+, 10.0.0.0/8+ ];
};
ipv6 {
import where net ~ [ fd00::/8+ ];
export where net ~ [ fd00::/8+ ];
};
interface "igp-dummy*"; interface "igp-dummy*";
interface "host0"; interface "host0";
interface "host0*"; interface "host0*";

View file

@ -18,6 +18,7 @@ routers:
unicastv6: fd32:6b0:70a6:179::2 unicastv6: fd32:6b0:70a6:179::2
pop_loc: us02 pop_loc: us02
solanum_sid: '9R2' solanum_sid: '9R2'
ansible_host: "h-dn42-router-us02.tail9a27a.ts.net"
us3.routers.9pfs.dn42: us3.routers.9pfs.dn42:
ansible_python_interpreter: "/usr/bin/python3" ansible_python_interpreter: "/usr/bin/python3"
machine_type: container machine_type: container

62
lg.yml Normal file
View file

@ -0,0 +1,62 @@
- name: Configure bird-lg-go on routers
hosts: routers
remote_user: root
tasks:
- name: Build looking glass destinations list
ansible.builtin.shell: echo {% for host in ansible_play_hosts %}{{ hostvars[host]['unicastv6'] }},{% endfor %}|sed 's/,$//'
register: lg_dests
run_once: true
delegate_to: 127.0.0.1
- name: Add Debian build dependencies
ansible.builtin.package:
name: make,git,golang-1.23
state: present
when: ansible_distribution == 'Debian'
- name: Make debian sane
ansible.builtin.file:
state: link
dest: /usr/local/bin/go
src: /usr/lib/go-1.23/bin/go
when: ansible_distribution == 'Debian'
- name: Add Arch build dependencies
ansible.builtin.pacman:
name: base-devel,go
state: present
when: ansible_distribution == 'Archlinux'
- name: Make bird-lg-go directory in /opt
ansible.builtin.file:
dest: /opt/bird-lg-go
state: directory
- name: Download bird-lg-go
ansible.builtin.git:
repo: https://github.com/xddxdd/bird-lg-go
dest: /opt/bird-lg-go/src
- name: Build bird-lg-go
ansible.builtin.make:
chdir: /opt/bird-lg-go/src
- name: Create proxy systemd service
ansible.builtin.template:
src: lg/proxy-service.j2
dest: /etc/systemd/system/bird-lg-go-proxy.service
mode: '0644'
when: ansible_service_mgr == 'systemd'
- name: Enable and start/reload bird-lg-go-proxy
ansible.builtin.systemd_service:
name: bird-lg-go-proxy.service
enabled: true
state: restarted
daemon_reload: true
when: ansible_service_mgr == 'systemd'
- name: Create frontend systemd service
ansible.builtin.template:
src: lg/frontend-service.j2
dest: /etc/systemd/system/bird-lg-go-frontend.service
mode: '0644'
when: ansible_service_mgr == 'systemd'
- name: Enable and start/reload bird-lg-go-frontend
ansible.builtin.systemd_service:
name: bird-lg-go-frontend.service
enabled: true
state: restarted
daemon_reload: true
when: ansible_service_mgr == 'systemd'

11
lg/frontend-service.j2 Normal file
View file

@ -0,0 +1,11 @@
[Unit]
Description=bird-lg-go frontend
[Service]
DynamicUser=yes
ExecStart=/opt/bird-lg-go/src/frontend/frontend --proxy-port 8000 --listen 8001 --dns-interface whois.dn42 --whois whois.dn42 --net-specific-mode dn42 --servers {{ lg_dests.stdout }}
Restart=on-failure
RestartSec=60
[Install]
WantedBy=multi-user.target

12
lg/proxy-service.j2 Normal file
View file

@ -0,0 +1,12 @@
[Unit]
Description=bird-lg-go proxy
After=bird.service
Before=bird-lg-go-frontend.service
[Service]
DynamicUser=yes
User=bird
ExecStart=/opt/bird-lg-go/src/proxy/proxy
[Install]
WantedBy=multi-user.target

View file

@ -2,6 +2,18 @@
hosts: routers hosts: routers
remote_user: root remote_user: root
tasks: tasks:
- name: Create src/ directory on playbook host
ansible.builtin.file:
path: src
state: directory
delegate_to: 127.0.0.1
run_once: true
- name: Clone bird-lg-go locally
ansible.builtin.git:
dest: src/bird-lg-go
repo: https://github.com/xddxdd/bird-lg-go
delegate_to: 127.0.0.1
run_once: true
- name: Create bird directory - name: Create bird directory
ansible.builtin.file: ansible.builtin.file:
path: /etc/bird path: /etc/bird