initial commit

This commit is contained in:
Vi Truchseß
2023-02-08 15:04:36 +01:00
commit bc06adc15a
5 changed files with 138 additions and 0 deletions

31
wg_server.j2 Normal file
View File

@@ -0,0 +1,31 @@
[Interface]
PrivateKey = {{ wg_key }}
ListenPort = {{ wg_port }}
{% if wg_ip4 | default(false) %}
Address = {{ wg_ip4 }}
{% endif %}
{% if wg_ip6 | default(false) %}
Address = {{ wg_ip6 }}
{% endif %}
{% if wg_extraconf | default(false) %}
{% for line in wg_extraconf %}
{{ line }}
{% endfor %}
{% endif %}
{% for clientname in groups['wg_clients'] %}
{% set ip4 = hostvars[clientname].wg_ip4 | default(false) %}
{% set ip6 = hostvars[clientname].wg_ip6 | default(false) %}
{% set wg_pubkey = pubkeys.results | selectattr('item', 'match', clientname) | map(attribute='stdout') | first %}
#{{ clientname }}
[Peer]
PublicKey = {{ wg_pubkey }}
{% if ip4 and ip6 %}
AllowedIPs = {{ ip4 }},{{ ip6 }}
{% elif ip4 %}
AllowedIPs = {{ ip4 }}
{% elif ip6 %}
AllowedIPs = {{ ip6 }}
{% endif %}
{% endfor %}