2022-01-21 20:29:34 +00:00
|
|
|
- name: Install wireguard tools
|
|
|
|
package:
|
|
|
|
name: "{{ item }}"
|
|
|
|
loop:
|
|
|
|
- wireguard-tools
|
|
|
|
- qrencode
|
|
|
|
|
2019-12-08 21:05:20 +00:00
|
|
|
- name: Wireguard server config
|
|
|
|
template:
|
2020-01-19 16:43:51 +00:00
|
|
|
src: files/wireguard-server.conf
|
2019-12-08 21:05:20 +00:00
|
|
|
dest: /etc/wireguard/wg0.conf
|
2020-09-26 17:53:47 +01:00
|
|
|
mode: "0600"
|
2022-01-11 20:51:12 +00:00
|
|
|
backup: true
|
2019-12-08 21:05:20 +00:00
|
|
|
register: wireguard_conf
|
|
|
|
|
|
|
|
- name: Enable wireguard
|
|
|
|
service:
|
|
|
|
name: wg-quick@wg0
|
|
|
|
enabled: true
|
2020-04-28 20:48:15 +01:00
|
|
|
|
|
|
|
- name: Restart wireguard
|
|
|
|
service:
|
|
|
|
name: wg-quick@wg0
|
|
|
|
state: restarted
|
2019-12-08 21:05:20 +00:00
|
|
|
when: wireguard_conf.changed
|
2020-01-19 16:43:51 +00:00
|
|
|
|
|
|
|
- name: Create wireguard client directory
|
|
|
|
file:
|
2023-06-17 16:00:30 +01:00
|
|
|
path: "{{ me.home }}/wireguard-clients"
|
2020-01-19 16:43:51 +00:00
|
|
|
state: directory
|
2023-06-15 15:16:19 +01:00
|
|
|
owner: "{{ me.user }}"
|
|
|
|
mode: "700"
|
2020-01-19 16:43:51 +00:00
|
|
|
|
|
|
|
- name: Wireguard client configuration
|
|
|
|
template:
|
|
|
|
src: files/wireguard-client.conf
|
2023-06-17 16:00:30 +01:00
|
|
|
dest: "{{ me.home }}/wireguard-clients/{{ item.key }}.conf"
|
2023-06-15 15:16:19 +01:00
|
|
|
owner: "{{ me.user }}"
|
|
|
|
mode: "600"
|
|
|
|
loop: "{{ wireguard.clients | dict2items }}"
|
2020-01-19 16:43:51 +00:00
|
|
|
loop_control:
|
|
|
|
label: "{{ item.key }}"
|