aboutsummaryrefslogtreecommitdiffstats
path: root/roles/wireguard/tasks/main.yml
diff options
context:
space:
mode:
authorbinary <me@rgoncalves.se>2020-11-20 19:20:55 +0100
committerbinary <me@rgoncalves.se>2020-11-20 19:20:55 +0100
commitc110f9a103c2f676917e3fe5e33f4eaedfed070c (patch)
tree072f1b019ae7d0c39a0cbd9d88257688203edddc /roles/wireguard/tasks/main.yml
parentb739e2af7060cd10f65d97cd0bfc0e9adb7a5490 (diff)
downloadinfrastructure-c110f9a103c2f676917e3fe5e33f4eaedfed070c.tar.gz
Refactor wireguard role with new host declaration.
Diffstat (limited to 'roles/wireguard/tasks/main.yml')
-rw-r--r--roles/wireguard/tasks/main.yml41
1 files changed, 23 insertions, 18 deletions
diff --git a/roles/wireguard/tasks/main.yml b/roles/wireguard/tasks/main.yml
index 9e23fa7..51b97c0 100644
--- a/roles/wireguard/tasks/main.yml
+++ b/roles/wireguard/tasks/main.yml
@@ -1,15 +1,19 @@
-# wireguard ~~ tasks/main.yml
+
+# wireguard ~~ roles/wireguard/tasks/main.yml
+# create keys and configuration for wireguard hosts
---
-- include: set_facts.yml
+- name: generate dynamic facts
+ include: set_facts.yml
-- stat:
+- name: check keys on local disk
+ stat:
path: "{{ wg_host_keys }}"
register: stat_host_keys
delegate_to: localhost
-- name: Generate domain keys
+- name: generate host keys
shell: |
umask 077
wg genkey | tee "{{ wg_host_keys }}" | wg pubkey >> "{{ wg_host_keys }}"
@@ -18,40 +22,41 @@
when: not stat_host_keys.stat.exists or force is defined and force
delegate_to: localhost
-- name: Create wireguard dir on remote host
+- name: create wireguard dir on remote host
file:
path: /etc/wireguard
- owner: root
+ owner: "{{ user_root }}"
+ group: "{{ group_root }}"
+ mode: 0700
state: directory
- mode: "0700"
ignore_unreachable: true
-- name: Generate client configuration
+- name: generate client configuration
template:
- src: templates/host.conf.j2
+ src: host.conf.j2
dest: "{{ item.path }}"
- mode: "0600"
- when: ansible_host != _i.dcontroller
+ mode: 0600
+ when: ansible_host != global.dcontroller
delegate_to: "{{ item.name }}"
loop:
- { name: "{{ ansible_host }}", path: /etc/wireguard/dcontroller.conf }
- - { name: localhost, path: "{{ wg_dir }}/{{ ansible_host}}.conf" }
+ - { name: localhost, path: "{{ wg_dir }}/{{ ansible_host }}.conf" }
ignore_unreachable: true
-- name: Generate server configuration
+- name: generate server configuration
template:
- src: templates/dcontroller.conf.j2
+ src: dcontroller.conf.j2
dest: "{{ item.path }}"
mode: "0600"
- when: ansible_host == _i.dcontroller
+ when: ansible_host == global.dcontroller
delegate_to: "{{ item.name }}"
loop:
- { name: "{{ ansible_host }}", path: /etc/wireguard/dcontroller.conf }
- - { name: localhost, path: "{{ wg_dir }}/{{ ansible_host}}.conf" }
+ - { name: localhost, path: "{{ wg_dir }}/{{ ansible_host }}.conf" }
-- name: Generate server interface
+- name: generate server interface
template:
src: templates/hostname.j2
dest: /etc/hostname.tun0
- when: ansible_host == _i.dcontroller
+ when: ansible_host == global.dcontroller
remember that computers suck.