1
0
Fork 0

use wg syncconf if available

This commit is contained in:
githubixx 2020-01-25 21:49:48 +01:00
parent f97210d2ad
commit dc56b0d39e
2 changed files with 26 additions and 1 deletions

View file

@ -3,3 +3,15 @@
service: service:
name: "wg-quick@{{ wireguard_interface }}" name: "wg-quick@{{ wireguard_interface }}"
state: restarted state: restarted
when: wg_syncconf == "false"
listen: "reconfigure wireguard"
- name: syncconf wireguard
shell: |
systemctl is-active wg-quick@wg-quick@{{ wireguard_interface|quote }} || systemctl start wg-quick@{{ wireguard_interface|quote }}
wg syncconf {{ wireguard_interface|quote }} <(wg-quick strip /etc/wireguard/{{ wireguard_interface|quote }}.conf)
exit 0
args:
executable: "/bin/bash"
when: wg_syncconf == "true"
listen: "reconfigure wireguard"

View file

@ -39,6 +39,19 @@
- wg-generate-keys - wg-generate-keys
- wg-config - wg-config
- name: Get wg subcommands
command: "wg --help"
register: wg_subcommands
- name: Set default value for wg_syncconf variable
set_fact:
wg_syncconf: "false"
- name: Check if wg syncconf subcommand is available
set_fact:
wg_syncconf: "true"
when: wg_subcommands.stdout | regex_search('syncconf:')
- block: - block:
- name: Generate WireGuard private key - name: Generate WireGuard private key
shell: "wg genkey" shell: "wg genkey"
@ -99,7 +112,7 @@
tags: tags:
- wg-config - wg-config
notify: notify:
- restart wireguard - reconfigure wireguard
- name: Check if reload-module-on-update is set - name: Check if reload-module-on-update is set
stat: stat: