|
|
@ -40,52 +40,59 @@ PostDown = {{ wg_postdown }}
|
|
|
|
SaveConfig = true
|
|
|
|
SaveConfig = true
|
|
|
|
{% endif %}
|
|
|
|
{% endif %}
|
|
|
|
{% for host in ansible_play_hosts %}
|
|
|
|
{% for host in ansible_play_hosts %}
|
|
|
|
{% if host != inventory_hostname %}
|
|
|
|
{% if host != inventory_hostname %}
|
|
|
|
|
|
|
|
|
|
|
|
[Peer]
|
|
|
|
[Peer]
|
|
|
|
# {{ host }}
|
|
|
|
# {{ host }}
|
|
|
|
PublicKey = {{hostvars[host].public_key}}
|
|
|
|
PublicKey = {{hostvars[host].public_key}}
|
|
|
|
{% if hostvars[host].wireguard_allowed_ips is defined %}
|
|
|
|
{% if hostvars[host].wireguard_allowed_ips is defined %}
|
|
|
|
AllowedIPs = {{hostvars[host].wireguard_allowed_ips}}
|
|
|
|
AllowedIPs = {{hostvars[host].wireguard_allowed_ips}}
|
|
|
|
{% else %}
|
|
|
|
{% else %}
|
|
|
|
AllowedIPs = {{hostvars[host].wireguard_ip}}/32
|
|
|
|
AllowedIPs = {{hostvars[host].wireguard_ip}}/32
|
|
|
|
{% endif %}
|
|
|
|
{% endif %}
|
|
|
|
{% if hostvars[host].wireguard_persistent_keepalive is defined %}
|
|
|
|
{% if hostvars[host].wireguard_persistent_keepalive is defined %}
|
|
|
|
PersistentKeepalive = {{hostvars[host].wireguard_persistent_keepalive}}
|
|
|
|
PersistentKeepalive = {{hostvars[host].wireguard_persistent_keepalive}}
|
|
|
|
{% endif %}
|
|
|
|
{% endif %}
|
|
|
|
{% if hostvars[host].wireguard_port is defined and hostvars[host].wireguard_port is number %}
|
|
|
|
{% if (
|
|
|
|
{% if hostvars[host].wireguard_endpoint is defined and hostvars[host].wireguard_endpoint != "" %}
|
|
|
|
hostvars[host].wireguard_dc is defined and
|
|
|
|
Endpoint = {{hostvars[host].wireguard_endpoint}}:{{hostvars[host].wireguard_port}}
|
|
|
|
hostvars[inventory_hostname].wireguard_dc is defined and
|
|
|
|
{% else %}
|
|
|
|
hostvars[inventory_hostname].wireguard_dc['name'] != hostvars[host].wireguard_dc['name']
|
|
|
|
Endpoint = {{host}}:{{hostvars[host].wireguard_port}}
|
|
|
|
)
|
|
|
|
{% endif %}
|
|
|
|
%}
|
|
|
|
{% elif hostvars[host].wireguard_endpoint is defined and hostvars[host].wireguard_endpoint != "" %}
|
|
|
|
Endpoint = {{hostvars[host].wireguard_dc['endpoint']}}:{{hostvars[host].wireguard_dc['port']}}
|
|
|
|
Endpoint = {{hostvars[host].wireguard_endpoint}}:{{wireguard_port}}
|
|
|
|
{% elif hostvars[host].wireguard_port is defined and hostvars[host].wireguard_port is number %}
|
|
|
|
{% elif hostvars[host].wireguard_endpoint == "" %}
|
|
|
|
{% if hostvars[host].wireguard_endpoint is defined and hostvars[host].wireguard_endpoint != "" %}
|
|
|
|
# No endpoint defined for this peer
|
|
|
|
Endpoint = {{hostvars[host].wireguard_endpoint}}:{{hostvars[host].wireguard_port}}
|
|
|
|
{% else %}
|
|
|
|
{% else %}
|
|
|
|
Endpoint = {{host}}:{{wireguard_port}}
|
|
|
|
Endpoint = {{host}}:{{hostvars[host].wireguard_port}}
|
|
|
|
{% endif %}
|
|
|
|
{% endif %}
|
|
|
|
{% endif %}
|
|
|
|
{% elif hostvars[host].wireguard_endpoint is defined and hostvars[host].wireguard_endpoint != "" %}
|
|
|
|
|
|
|
|
Endpoint = {{hostvars[host].wireguard_endpoint}}:{{wireguard_port}}
|
|
|
|
|
|
|
|
{% elif hostvars[host].wireguard_endpoint == "" %}
|
|
|
|
|
|
|
|
# No endpoint defined for this peer
|
|
|
|
|
|
|
|
{% else %}
|
|
|
|
|
|
|
|
Endpoint = {{host}}:{{wireguard_port}}
|
|
|
|
|
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
{% endif %}
|
|
|
|
{% endfor %}
|
|
|
|
{% endfor %}
|
|
|
|
{% if wireguard_unmanaged_peers is defined %}
|
|
|
|
{% if wireguard_unmanaged_peers is defined %}
|
|
|
|
|
|
|
|
|
|
|
|
# Peers not managed by ansible from wireguard_unmanaged_peers
|
|
|
|
# Peers not managed by Ansible from "wireguard_unmanaged_peers" variable
|
|
|
|
{% for peer in wireguard_unmanaged_peers.keys() %}
|
|
|
|
{% for peer in wireguard_unmanaged_peers.keys() %}
|
|
|
|
[Peer]
|
|
|
|
[Peer]
|
|
|
|
# {{ peer }}
|
|
|
|
# {{ peer }}
|
|
|
|
PublicKey = {{ wireguard_unmanaged_peers[peer].public_key }}
|
|
|
|
PublicKey = {{ wireguard_unmanaged_peers[peer].public_key }}
|
|
|
|
{% if wireguard_unmanaged_peers[peer].preshared_key is defined %}
|
|
|
|
{% if wireguard_unmanaged_peers[peer].preshared_key is defined %}
|
|
|
|
PresharedKey = {{ wireguard_unmanaged_peers[peer].preshared_key }}
|
|
|
|
PresharedKey = {{ wireguard_unmanaged_peers[peer].preshared_key }}
|
|
|
|
{% endif %}
|
|
|
|
{% endif %}
|
|
|
|
{% if wireguard_unmanaged_peers[peer].allowed_ips is defined %}
|
|
|
|
{% if wireguard_unmanaged_peers[peer].allowed_ips is defined %}
|
|
|
|
AllowedIPs = {{ wireguard_unmanaged_peers[peer].allowed_ips }}
|
|
|
|
AllowedIPs = {{ wireguard_unmanaged_peers[peer].allowed_ips }}
|
|
|
|
{% endif %}
|
|
|
|
{% endif %}
|
|
|
|
{% if wireguard_unmanaged_peers[peer].endpoint is defined %}
|
|
|
|
{% if wireguard_unmanaged_peers[peer].endpoint is defined %}
|
|
|
|
Endpoint = {{ wireguard_unmanaged_peers[peer].endpoint }}
|
|
|
|
Endpoint = {{ wireguard_unmanaged_peers[peer].endpoint }}
|
|
|
|
{% endif %}
|
|
|
|
{% endif %}
|
|
|
|
{% if wireguard_unmanaged_peers[peer].persistent_keepalive is defined %}
|
|
|
|
{% if wireguard_unmanaged_peers[peer].persistent_keepalive is defined %}
|
|
|
|
PersistentKeepalive = {{ wireguard_unmanaged_peers[peer].persistent_keepalive }}
|
|
|
|
PersistentKeepalive = {{ wireguard_unmanaged_peers[peer].persistent_keepalive }}
|
|
|
|
{% endif %}
|
|
|
|
{% endif %}
|
|
|
|
{% endfor %}
|
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
|
|
|
{% endif %}
|
|
|
|