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"
|
2019-12-08 21:05:20 +00:00
|
|
|
backup: yes
|
|
|
|
become: true
|
|
|
|
register: wireguard_conf
|
|
|
|
|
|
|
|
- name: Enable wireguard
|
|
|
|
service:
|
|
|
|
name: wg-quick@wg0
|
|
|
|
enabled: true
|
2020-04-28 20:48:15 +01:00
|
|
|
become: true
|
|
|
|
|
|
|
|
- name: Restart wireguard
|
|
|
|
service:
|
|
|
|
name: wg-quick@wg0
|
|
|
|
state: restarted
|
2019-12-08 21:05:20 +00:00
|
|
|
when: wireguard_conf.changed
|
|
|
|
become: true
|
2020-01-19 16:43:51 +00:00
|
|
|
|
|
|
|
- name: Create wireguard client directory
|
|
|
|
file:
|
2020-01-19 17:33:14 +00:00
|
|
|
path: "{{ home }}/wireguard-clients"
|
2020-01-19 16:43:51 +00:00
|
|
|
state: directory
|
2020-01-19 17:33:14 +00:00
|
|
|
owner: "{{ user }}"
|
|
|
|
mode: 0700
|
2020-01-19 16:43:51 +00:00
|
|
|
|
|
|
|
- name: Wireguard client configuration
|
|
|
|
template:
|
|
|
|
src: files/wireguard-client.conf
|
2020-01-19 17:33:14 +00:00
|
|
|
dest: "{{ home }}/wireguard-clients/{{ item.key }}.conf"
|
|
|
|
owner: "{{ user }}"
|
|
|
|
mode: 0600
|
2020-01-19 16:43:51 +00:00
|
|
|
loop: "{{ wireguard.clients|dict2items }}"
|
|
|
|
loop_control:
|
|
|
|
label: "{{ item.key }}"
|
2020-05-09 20:07:19 +01:00
|
|
|
|
|
|
|
- name: Enable p2p communication
|
|
|
|
sysctl:
|
|
|
|
name: net.ipv4.ip_forward
|
2020-06-18 21:18:47 +01:00
|
|
|
value: "1"
|
2020-05-09 20:07:19 +01:00
|
|
|
sysctl_set: yes
|
|
|
|
state: present
|
|
|
|
reload: yes
|
2020-05-16 16:15:58 +01:00
|
|
|
sysctl_file: /etc/sysctl.d/99-sysctl.conf
|
2020-05-09 20:07:19 +01:00
|
|
|
become: true
|
2020-05-11 11:59:46 +01:00
|
|
|
|
|
|
|
- name: Install wireguard tools
|
|
|
|
package:
|
|
|
|
name: "{{ item }}"
|
|
|
|
become: true
|
|
|
|
loop:
|
|
|
|
- wireguard-tools
|
|
|
|
- qrencode
|