Output wireguard client config files

This commit is contained in:
Jake Howard 2020-01-19 16:43:51 +00:00
parent f6ffb1ceef
commit 251fe11113
Signed by: jake
GPG Key ID: 57AFB45680EDD477
3 changed files with 30 additions and 1 deletions

View File

@ -0,0 +1,10 @@
[Interface]
Address = {{ item.value.ip }}
PrivateKey = {{ item.value.private_key }}
[Peer]
PublicKey = {{ wireguard.server.public_key }}
Endpoint = {{ wireguard.public_ip }}:{{ wireguard.port }}
AllowedIPs = {{ item.value.ip }}/32
PersistentKeepalive = 25

View File

@ -32,7 +32,7 @@
- name: Wireguard server config
template:
src: files/wireguard.conf
src: files/wireguard-server.conf
dest: /etc/wireguard/wg0.conf
backup: yes
become: true
@ -47,3 +47,22 @@
when: wireguard_conf.changed
become: true
become_user: root
- name: Create wireguard client directory
file:
path: /etc/wireguard/clients
state: directory
become: true
become_user: root
- name: Wireguard client configuration
template:
src: files/wireguard-client.conf
dest: /etc/wireguard/clients/{{ item.key }}.conf
backup: yes
become: true
become_user: root
loop: "{{ wireguard.clients|dict2items }}"
loop_control:
label: "{{ item.key }}"