aboutsummaryrefslogtreecommitdiffstats
path: root/roles/wireguard/tasks/server.yml
diff options
context:
space:
mode:
Diffstat (limited to 'roles/wireguard/tasks/server.yml')
-rw-r--r--roles/wireguard/tasks/server.yml37
1 files changed, 37 insertions, 0 deletions
diff --git a/roles/wireguard/tasks/server.yml b/roles/wireguard/tasks/server.yml
new file mode 100644
index 0000000..aac9197
--- /dev/null
+++ b/roles/wireguard/tasks/server.yml
@@ -0,0 +1,37 @@
+
+# wireguard ~~ roles/wireguard/tasks/main.yml
+# create keys and configuration for wireguard hosts
+
+---
+
+- name: generate server configuration
+ template:
+ src: dcontroller.conf.j2
+ dest: "{{ wg_dir }}/{{ ansible_host }}.conf"
+ mode: "0600"
+ when: ansible_host == global.dcontroller
+ delegate_to: localhost
+
+- name: generate server interface
+ template:
+ src: templates/hostname.j2
+ dest: /etc/hostname.tun0
+
+# NOTE: interface destruction and creation exists in the same tasks,
+# to avoid being kicked out of the ssh sessions if this one exists
+# within the current VPN.
+- name: restart wireguard interface
+ shell: |
+ ifconfig tun0 destroy
+ sh /etc/netstart tun0
+ register: result
+
+- name: show debug output
+ debug:
+ msg: |
+ {% for line in result.stdout_lines %}
+ "{{ line }}"
+ {% endfor %}
+ {% for line in result.stderr_lines %}
+ "{{ line }}"
+ {% endfor %}
remember that computers suck.