infrastructure/ansible/roles/gateway/tasks/wireguard.yml

61 lines
1.3 KiB
YAML
Raw Normal View History

2019-12-08 20:16:42 +00:00
- name: Add unstable apt repo
lineinfile:
path: /etc/apt/sources.list.d/unstable.list
state: present
2020-03-25 21:27:15 +00:00
line: deb http://deb.debian.org/debian/ unstable main
2019-12-08 20:16:42 +00:00
register: install_unstable_apt
become: true
- name: Limit unstable apt repo
copy:
src: limit-unstable.conf
dest: /etc/apt/preferences.d/limit-unstable
become: true
register: limit_unstable_apt
- name: Update apt repos
apt:
update_cache: true
become: true
when: install_unstable_apt.changed or limit_unstable_apt.changed
- name: Install Wireguard
apt:
name:
- wireguard
- wireguard-tools
become: true
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
backup: yes
become: true
register: wireguard_conf
- name: Enable wireguard
service:
name: wg-quick@wg0
state: reloaded
2019-12-08 21:05:20 +00:00
enabled: true
when: wireguard_conf.changed
become: true
2020-01-19 16:43:51 +00:00
- name: Create wireguard client directory
file:
path: "{{ home }}/wireguard-clients"
2020-01-19 16:43:51 +00:00
state: directory
owner: "{{ user }}"
mode: 0700
2020-01-19 16:43:51 +00:00
- name: Wireguard client configuration
template:
src: files/wireguard-client.conf
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 }}"