adc/ansible/roles/wg_vpn/tasks/main.yml

37 lines
1.1 KiB
YAML

---
# tasks file for wg_vpn
# playbook to go from a "base configured" server to a wg vpn peer
- name: add unstable to repos
shell: |
echo "deb http://deb.debian.org/debian/ unstable main" > /etc/apt/sources.list.d/unstable.list
printf 'Package: *\nPin: release a=unstable\nPin-Priority: 90\n' > /etc/apt/preferences.d/limit-unstable
- name: install wireguard
apt:
# hardcoded header here is for digital oceans :(
name:
- wireguard
- build-essential
- dkms
- linux-headers-4.19.0-6-cloud-amd64
update_cache: yes
state: latest
- name: Enable IP forwarding
sysctl: name={{ item }} value=1 state=present
with_items:
- net.ipv4.ip_forward
- net.ipv6.conf.all.forwarding
- name: Create wireguard config directory
file: state=directory path=/etc/wireguard owner=root group=root mode=0700
- name: Install wireguard configuration
template: src=wg0.conf dest=/etc/wireguard/wg0.conf owner=root group=root mode=0600
notify: restart wireguard
- name: Start wireguard
service: name=wg-quick@wg0.service enabled=yes state=started