wireguard: clean up

- make variables less clunky
- make docker-compose run after wireguard (this seems janky right now)
This commit is contained in:
dogeystamp 2024-06-17 17:48:29 -04:00
parent 0c8d18dcce
commit c70e33e629
Signed by: dogeystamp
GPG Key ID: 7225FE3592EFFA38
6 changed files with 14 additions and 4 deletions

View File

@ -45,4 +45,6 @@ escalation_method: doas
enable_connection: yes
# use a wireguard network between bastion and fleet host for the reverse proxy
# see roles/wireguard/defaults/main.yml for further config settings
wireguard_services: true
wireguard_interface: "wg0"

View File

@ -1,7 +1,12 @@
[Unit]
Description=Services manager with docker-compose
{% if wireguard_services %}
Requires=docker.service wg-quick@{{ wireguard_interface }}.service
After=docker.service wg-quick@{{ wireguard_interface }}.service
{% else %}
Requires=docker.service
After=docker.service
{% endif %}
[Service]
User=docker

View File

@ -6,10 +6,13 @@
# also see group_vars/all/00-secret-template.yml
# this key is defined in group_vars/all/50-vars.yml
# it's duplicated here just in case
wireguard_interface: "wg0"
wireguard:
dns_servers:
- "{{ dns_forward }}"
interface: "wg0"
ip:
# cidr range in tunnel
cidr: "10.66.77.0/24"

View File

@ -2,7 +2,7 @@
- name: Start wireguard
systemd:
name: "wg-quick@{{ wireguard.interface }}.service"
name: "wg-quick@{{ wireguard_interface }}.service"
enabled: yes
daemon_reload: yes
state: restarted

View File

@ -28,7 +28,7 @@
- name: Deploy wireguard server config
template:
src: server.conf.j2
dest: "/etc/wireguard/{{ wireguard.interface }}.conf"
dest: "/etc/wireguard/{{ wireguard_interface }}.conf"
owner: root
group: root
mode: 0600

View File

@ -1,5 +1,5 @@
[Interface]
Address = {{ hostvars[inventory_hostname]["vpn_ip"] }}/32
Address = {{ vpn_ip }}/32
PrivateKey = {{ wireguard_secret.servers[inventory_hostname].priv }}
ListenPort = {{ wireguard.ip.port }}