setup wireguard depending on vars

This commit is contained in:
rene
2022-03-10 11:41:34 +01:00
parent 4c637cd141
commit 406a60b513
2 changed files with 15 additions and 0 deletions

View File

@@ -2,6 +2,7 @@
# Load distro specific variables # Load distro specific variables
- include_vars: "{{ ansible_distribution }}.yml" - include_vars: "{{ ansible_distribution }}.yml"
tags: always tags: always
- include:vars: "{{ ansible_fqdn }}.yml"
- block: - block:
- include_tasks: system_setup/hosts.yml - include_tasks: system_setup/hosts.yml

View File

@@ -8,6 +8,20 @@
cmd: umask 077 && wg genkey | tee privatekey | wg pubkey > publickey cmd: umask 077 && wg genkey | tee privatekey | wg pubkey > publickey
chdir: /etc/wireguard chdir: /etc/wireguard
creates: /etc/wireguard/publickey creates: /etc/wireguard/publickey
when:
- wg_privkey is not defined
- wg_pubkey is not defined
- name: server | utilities | wireguard copy keys
copy:
content: "{{ item.key }}"
dest: "{{ item.keyfile }}"
loop:
- { key: wg_pubkey, keyfile: "/etc/wireguard/publickey" }
- { key: wg_privkey, keyfile: "/etc/wireguard/privatekey" }
when:
- wg_pubkey is defined
- wg_privkey is defined
- name: server | utilities | wireguard generate config - name: server | utilities | wireguard generate config
template: template: