infrastructure/ansible/roles/gateway/tasks/wireguard.yml
Jake Howard d5a7a61171
All checks were successful
/ terraform (push) Successful in 38s
/ ansible (push) Successful in 1m30s
Remove unnecessary use of become from some roles
This should make execution much faster
2024-09-09 17:09:03 +01:00

42 lines
925 B
YAML

- name: Install wireguard tools
package:
name: "{{ item }}"
loop:
- wireguard-tools
- qrencode
- name: Wireguard server config
template:
src: files/wireguard-server.conf
dest: /etc/wireguard/wg0.conf
mode: "0600"
backup: true
register: wireguard_conf
- name: Enable wireguard
service:
name: wg-quick@wg0
enabled: true
- name: Restart wireguard
service:
name: wg-quick@wg0
state: restarted
when: wireguard_conf.changed
- name: Create wireguard client directory
file:
path: "{{ me.home }}/wireguard-clients"
state: directory
owner: "{{ me.user }}"
mode: "700"
- name: Wireguard client configuration
template:
src: files/wireguard-client.conf
dest: "{{ me.home }}/wireguard-clients/{{ item.key }}.conf"
owner: "{{ me.user }}"
mode: "600"
loop: "{{ wireguard.clients | dict2items }}"
loop_control:
label: "{{ item.key }}"