infra/playbooks/roles/wireguard-endpoint/tasks/main.yml

41 lines
806 B
YAML
Raw Permalink Normal View History

2024-03-24 22:51:07 -04:00
---
- name: Install wireguard
ansible.builtin.apt:
name:
- wireguard
state: latest
- name: Copy config
ansible.builtin.copy:
src: wireguard.cfg
dest: /etc/wireguard/hatecomputers.conf
owner: root
group: root
mode: 0600
- name: Enable and persist ip forwarding
ansible.builtin.sysctl:
name: net.ipv4.ip_forward
value: "1"
state: present
sysctl_set: true
reload: true
- name: Allow wireguard endpoint ufw
ansible.builtin.ufw:
rule: allow
port: '51820'
proto: 'udp'
- name: Start wireguard and enable on boot
ansible.builtin.systemd:
name: wg-quick@hatecomputers
enabled: true
state: started
- name: Hotreload wireguard
ansible.builtin.shell: >
bash -c
"wg syncconf inframesh <(wg-quick strip inframesh)"