Use list of all peers

This commit is contained in:
Antonio J. Delgado 2022-11-04 17:55:00 +02:00
parent 8ba1bd81d6
commit 708a29ed99
2 changed files with 13 additions and 8 deletions

View file

@ -7,8 +7,9 @@
- Restart Wireguard service - Restart Wireguard service
- name: Register private key - name: Register private key
shell: cat /etc/wireguard/privatekey slurp:
register: privatekey src: /etc/wireguard/privatekey
register: private_key
- name: Ensure Wireguard client is configure - name: Ensure Wireguard client is configure
template: template:

View file

@ -1,10 +1,14 @@
[Interface] [Interface]
Address = {{ addresses[ansible_hostname] }} Address = {{ addresses[ansible_hostname] }}
PrivateKey = {{ privatekey.stdout }} PrivateKey = {{ private_key }}
ListenPort = {{ listenport }} ListenPort = {{ listenport }}
# Server: {% for item in wireguard_peers %}
# Peer name: {{ item.name }}
[Peer] [Peer]
PublicKey = {{ server_publickey }} PublicKey = {{ item.PublicKey }}
AllowedIPs = {{ allowed_ips }} AllowedIPs = {{ item.AllowedIPs }}
EndPoint = {{ endpoint }} {% if item.EndPointIP is defined and item.EndPointIP != '' %}
EndPoint = {{ item.EndPointIP }}:{{ listenport }}
{% endfor %}