Output wireguard client config files
This commit is contained in:
parent
f6ffb1ceef
commit
251fe11113
3 changed files with 30 additions and 1 deletions
10
ansible/roles/gateway/files/wireguard-client.conf
Normal file
10
ansible/roles/gateway/files/wireguard-client.conf
Normal 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
|
|
@ -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 }}"
|
||||||
|
|
Loading…
Reference in a new issue