ansible-role-wireguard/handlers/main.yml

28 lines
751 B
YAML
Raw Normal View History

---
- name: restart wireguard
service:
2019-01-07 22:56:20 +01:00
name: "wg-quick@{{ wireguard_interface }}"
state: "{{ item }}"
loop:
- stopped
- started
when: >
not wg_syncconf and
not ansible_os_family == 'Darwin'
listen: "reconfigure wireguard"
- name: syncconf wireguard
shell: |
set -o errexit
set -o pipefail
set -o nounset
2020-09-22 23:38:46 +03:00
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: >
wg_syncconf and
not ansible_os_family == 'Darwin'
listen: "reconfigure wireguard"