1
0
Fork 0
This repository has been archived on 2020-08-04. You can view files and clone it, but cannot push or open issues or pull requests.
ansible-role-wireguard/templates/wg.conf.j2
Robert Wimmer d197bd980d
Inital implementation (#1)
* initial implementation - part 1

* first working version

* add handler

* separate includes for Debian based and Archlinux OS

* refactor

* update

* add meta tag

* added ArchLinux to galaxy meta info

* rename file / add more Wiregurad config options

* fix typo

* update README

* update README

* fixed typos

* update README / variable rename: wireguard_ip -> wireguard_address
2018-08-12 22:21:45 +02:00

39 lines
1.4 KiB
Django/Jinja

#jinja2: lstrip_blocks:"True",trim_blocks:"True"
[Interface]
Address = {{hostvars[inventory_hostname].wireguard_address}}
PrivateKey = {{private_key}}
ListenPort = {{wireguard_port}}
{% if hostvars[inventory_hostname].wireguard_dns is defined %}
DNS = {{hostvars[inventory_hostname].wireguard_dns}}
{% endif %}
{% if hostvars[inventory_hostname].wireguard_postup is defined %}
PostUp = {{hostvars[inventory_hostname].wireguard_postup}}
{% endif %}
{% if hostvars[inventory_hostname].wireguard_postdown is defined %}
PostDown = {{hostvars[inventory_hostname].wireguard_postdown}}
{% endif %}
{% if hostvars[inventory_hostname].wireguard_save_config is defined %}
SaveConfig = true
{% endif %}
{% for host in groups["vpn"] %}
{% if host != inventory_hostname %}
[Peer]
PublicKey = {{hostvars[host].public_key}}
{% if hostvars[host].wireguard_allowed_ips is defined %}
AllowedIPs = {{hostvars[host].wireguard_allowed_ips}}
{% else %}
AllowedIPs = {{hostvars[host].wireguard_ip}}/32
{% endif %}
{% if hostvars[host].wireguard_persistent_keepalive is defined %}
PersistentKeepalive = {{hostvars[host].wireguard_persistent_keepalive}}
{% endif %}
{% if hostvars[host].wireguard_endpoint is not defined %}
Endpoint = {{host}}:{{wireguard_port}}
{% elif hostvars[host].wireguard_endpoint != "" %}
Endpoint = {{hostvars[host].wireguard_endpoint}}:{{wireguard_port}}
{% endif %}
{% endif %}
{% endfor %}