ansible/roles/wireguard-endpoint/tasks/main.yml
Jeltz ea87aa7ec1
Some checks failed
continuous-integration/drone/push Build is failing
WIP: Create a role for a Wireguard VPN endpoint
2021-01-31 06:07:05 +01:00

60 lines
1.2 KiB
YAML

---
- name: Install required packages
apt:
pkg:
- ifupdown2
- wireguard
- nftables
state: latest
update_cache: yes
- name: Tweak sysctl to enable IP forwarding
template:
src: sysctl.conf.j2
dest: /etc/sysctl.d/forwarding.conf
owner: root
group: root
mode: u=rw,g=r,o=
- name: Create tunnels configurations
template:
src: wireguard.conf.j2
dest: "/etc/wireguard/{{ item.name }}.conf"
owner: root
group: root
mode: u=rw,g=,o=
loop: "{{ wireguard_endpoints }}"
# try to hide clear-text private keys from Ansible output
no_log: True
diff: no
- name: Create network interfaces
template:
src: interface.j2
dest: "/etc/network/interfaces.d/{{ item.name }}"
owner: root
group: root
mode: u=rw,g=r,o=
loop: "{{ wireguard_endpoints }}"
no_log: True
diff: no
notify:
- Reload network interfaces
- name: Enable nftables
systemd:
name: nftables.service
state: started
enabled: yes
- name: Configure nftables
template:
src: nftables.conf.j2
dest: /etc/nftables.conf
validate: /sbin/nft -c -f %s
owner: root
group: root
mode: u=rw,g=r,o=
notify:
- Reload nftables
...