aboutsummaryrefslogtreecommitdiffstats
path: root/roles/wireguard/tasks/generate.yml
diff options
context:
space:
mode:
Diffstat (limited to 'roles/wireguard/tasks/generate.yml')
-rw-r--r--roles/wireguard/tasks/generate.yml29
1 files changed, 29 insertions, 0 deletions
diff --git a/roles/wireguard/tasks/generate.yml b/roles/wireguard/tasks/generate.yml
new file mode 100644
index 0000000..6b91fb2
--- /dev/null
+++ b/roles/wireguard/tasks/generate.yml
@@ -0,0 +1,29 @@
+
+# wireguard ~~ roles/wireguard/tasks/generate.yml
+# generate client configuration
+
+---
+
+- name: check keys on local disk
+ stat:
+ path: "{{ wg_host_keys }}"
+ register: stat_host_keys
+ delegate_to: localhost
+
+- name: generate host keys on local machine
+ shell: |
+ umask 077
+ wg genkey | tee "{{ wg_host_keys }}" | wg pubkey >> "{{ wg_host_keys }}"
+ args:
+ chdir: "{{ wg_dir }}"
+ when: not stat_host_keys.stat.exists or wg_force is defined and wg_force
+ delegate_to: localhost
+
+- name: generate client configuration
+ template:
+ src: host.conf.j2
+ dest: "{{ wg_dir }}/{{ ansible_host }}.conf"
+ mode: "0600"
+ when: ansible_host != global.dcontroller
+ delegate_to: localhost
+
remember that computers suck.