aboutsummaryrefslogtreecommitdiff
path: root/roles/wireguard_client/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'roles/wireguard_client/tasks')
-rw-r--r--roles/wireguard_client/tasks/main.yaml36
1 files changed, 36 insertions, 0 deletions
diff --git a/roles/wireguard_client/tasks/main.yaml b/roles/wireguard_client/tasks/main.yaml
new file mode 100644
index 0000000..04814ba
--- /dev/null
+++ b/roles/wireguard_client/tasks/main.yaml
@@ -0,0 +1,36 @@
+# https://dev.to/tangramvision/exploring-ansible-via-setting-up-a-wireguard-vpn-3389
+---
+
+- name: 'Enable Debian 10 buster backports repo'
+ shell:
+ cmd: 'echo "deb http://deb.debian.org/debian buster-backports main contrib non-free" > /etc/apt/sources.list.d/buster-backports.list'
+ creates: '/etc/apt/sources.list.d/buster-backports.list'
+
+- name: 'Install Wireguard'
+ apt:
+ name: 'wireguard'
+ state: 'present'
+ update_cache: true
+
+- name: 'enable and persist ip forwarding'
+ sysctl:
+ name: 'net.ipv4.ip_forward'
+ value: "1"
+ state: 'present'
+ sysctl_set: true
+ reload: true
+
+- name: 'generate private key'
+ shell:
+ cmd: 'umask 077 && wg genkey | tee privatekey | wg pubkey > publickey'
+ chdir: '/etc/wireguard'
+ creates: '/etc/wireguard/publickey'
+
+- name: 'create client wireguard config'
+ template:
+ dest: '/etc/wireguard/wg0.conf'
+ src: 'wg0.conf.j2'
+ owner: 'root'
+ group: 'root'
+ mode: '600'
+ notify: 'restart wireguard'