ansible/roles/wireguard/templates/wireguard/tunnel.conf.j2

48 lines
1.1 KiB
Django/Jinja

{{ ansible_header | comment }}
[Interface]
{% if item.addresses is defined %}
Address = {{ item.addresses | join(", ") }}
{% endif %}
{% if item.listen_port is defined %}
ListenPort = {{ item.listen_port }}
{% endif %}
PrivateKey = {{ item.private_key }}
{% if item.table is defined %}
Table = {{ item.table }}
{% endif %}
{% if item.pre_up is defined %}
{% for command in item.pre_up %}
PreUp = {{ command }}
{% endfor %}
{% endif %}
{% if item.post_up is defined %}
{% for command in item.post_up %}
PostUp = {{ command }}
{% endfor %}
{% endif %}
{% if item.pre_down is defined %}
{% for command in item.pre_down %}
PreDown = {{ command }}
{% endfor %}
{% endif %}
{% if item.post_down is defined %}
{% for command in item.post_down %}
PostDown = {{ command }}
{% endfor %}
{% endif %}
{% for peer in item.peers %}
[Peer]
PublicKey = {{ peer.public_key }}
AllowedIPs = {{ peer.allowed_ips | join(", ") }}
{% if peer.endpoint is defined %}
Endpoint = {{ peer.endpoint }}
{% endif %}
{% if peer.persistent_keepalive is defined %}
PersistentKeepalive = {{ peer.persistent_keepalive }}
{% endif %}
{% endfor -%}