Add also peers
This commit is contained in:
parent
0ed9893687
commit
c7b48bed66
1 changed files with 14 additions and 1 deletions
|
@ -4,11 +4,24 @@ PrivateKey = {{ private_key }}
|
||||||
ListenPort = {{ listenport }}
|
ListenPort = {{ listenport }}
|
||||||
{% if vpn_dns is defined %}DNS = {{ vpn_dns }}{% endif %}
|
{% if vpn_dns is defined %}DNS = {{ vpn_dns }}{% endif %}
|
||||||
|
|
||||||
|
# From inventory
|
||||||
{% for item in groups['wireguard_clients'] %}{% if hostvars[item]['inventory_hostname'] != inventory_hostname and 'PublicKey' in hostvars[item] and 'AllowedIPs' in hostvars[item] %}
|
{% for item in groups['wireguard_clients'] %}{% if hostvars[item]['inventory_hostname'] != inventory_hostname and 'PublicKey' in hostvars[item] and 'AllowedIPs' in hostvars[item] %}
|
||||||
|
|
||||||
# Peer name: {{ item }}
|
# Peer name: {{ item }}
|
||||||
[Peer]
|
[Peer]
|
||||||
PublicKey = {{ hostvars[item]['PublicKey'] }}
|
PublicKey = {{ hostvars[item]['PublicKey'] }}
|
||||||
AllowedIPs = {{ hostvars[item]['AllowedIPs'] }}
|
AllowedIPs = {{ hostvars[item]['AllowedIPs'] }}
|
||||||
{% if hostvars[item]['EndPointIP'] is defined and hostvars[item]['EndPointIP'] != '' %}EndPoint = {{ hostvars[item]['EndPointIP'] }}:{{ hostvars[item]['listenport'] | default(listenport) }}
|
{% if hostvars[item]['EndPointIP'] is defined and hostvars[item]['EndPointIP'] != '' %}EndPoint = {{ hostvars[item]['EndPointIP'] }}:{{ hostvars[item]['listenport'] | default(listenport) }}
|
||||||
{% endif %}{% endif %}{% endfor %}
|
{% endif %}{% endif %}{% endfor %}
|
||||||
|
|
||||||
|
# From peers configuration
|
||||||
|
{% for item in wireguard_peers %}{% if item['name'] != inventory_hostname and 'PublicKey' in item and 'AllowedIPs' in item %}
|
||||||
|
|
||||||
|
# Peer name: {{ item.name }}
|
||||||
|
[Peer]
|
||||||
|
PublicKey = {{ item.PublicKey }}
|
||||||
|
AllowedIPs = {{ item.AllowedIPs }}
|
||||||
|
{% if item.EndPointIP is defined and item.EndPointIP != '' %}
|
||||||
|
EndPoint = {{ item.EndPointIP }}:{{ listenport }}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}{% endfor %}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue