|
|
|
---
|
|
|
|
# Copyright (C) 2018-2022 Robert Wimmer
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
|
|
|
- name: Restart wireguard
|
|
|
|
ansible.builtin.service:
|
|
|
|
name: "wg-quick@{{ wireguard_interface }}"
|
|
|
|
state: "{{ item }}"
|
|
|
|
loop:
|
|
|
|
- stopped
|
|
|
|
- started
|
|
|
|
when:
|
|
|
|
- wireguard__restart_interface
|
|
|
|
- not ansible_os_family == 'Darwin'
|
|
|
|
- wireguard_service_enabled == "yes"
|
|
|
|
listen: "reconfigure wireguard"
|
|
|
|
|
|
|
|
- name: Syncconf wireguard
|
|
|
|
ansible.builtin.shell: |
|
|
|
|
set -o errexit
|
|
|
|
set -o pipefail
|
|
|
|
set -o nounset
|
|
|
|
systemctl is-active 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:
|
|
|
|
- not wireguard__restart_interface
|
|
|
|
- not ansible_os_family == 'Darwin'
|
|
|
|
- wireguard_service_enabled == "yes"
|
|
|
|
listen: "reconfigure wireguard"
|