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 - name: Wireguard server config
template: template:
src: files/wireguard.conf src: files/wireguard-server.conf
dest: /etc/wireguard/wg0.conf dest: /etc/wireguard/wg0.conf
backup: yes backup: yes
become: true become: true
@ -47,3 +47,22 @@
when: wireguard_conf.changed when: wireguard_conf.changed
become: true become: true
become_user: root 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 }}"