Configure wireguard VPN

This commit is contained in:
Pijus Kamandulis
2024-05-29 22:06:22 +03:00
parent dd5869a62d
commit d779db5d34
4 changed files with 79 additions and 2 deletions

View File

@@ -0,0 +1,13 @@
{% set _wg = lookup('vars', inventory_hostname + '_wg') %}
# {{ ansible_managed }}
[Interface]
PrivateKey = {{ _wg.private_key }}
ListenPort = {{ _wg.port }}
{% for peer in _wg.peers %}
[Peer]
# {{ peer.name }}
PublicKey = {{ peer.public_key }}
Endpoint = {{ peer.endpoint }}
AllowedIPs = {{ peer.allowed_ips }}
{% endfor %}

View File

@@ -0,0 +1,6 @@
{% set _wg = lookup('vars', inventory_hostname + '_wg') %}
# {{ ansible_managed }}
inet {{ _wg.address }} 255.255.255.0 NONE
up
!/usr/local/bin/wg setconf {{ _wg.interface }} /etc/wireguard/{{ _wg.interface }}.conf