added wg-quick restart and sudo

This commit is contained in:
2024-11-20 19:14:20 +01:00
parent 15acffab5e
commit 20469486fe

View File

@@ -1,5 +1,6 @@
- name: Setup Wireguard server - name: Setup Wireguard server
hosts: wg_server hosts: wg_server
become: yes
tasks: tasks:
- name: Install wireguard - name: Install wireguard
apt: apt:
@@ -32,7 +33,10 @@
enabled: true enabled: true
handlers: handlers:
- name: read wg config - name: read wg config
shell: "wg syncconf {{ wg_interface }} <(wg-quick strip {{ wg_interface }})" service:
name: "wg-quick@{{ wg_interface }}"
state: restarted
# shell: "wg syncconf {{ wg_interface }} <(wg-quick strip {{ wg_interface }})"
# command: "wg setconf {{ wg_interface }} /etc/wireguard/{{ wg_interface }}.conf" # command: "wg setconf {{ wg_interface }} /etc/wireguard/{{ wg_interface }}.conf"
# - name: reload interface # - name: reload interface
# shell: "ifdown {{ wg_interface }}; ifup {{ wg_interface }}" # shell: "ifdown {{ wg_interface }}; ifup {{ wg_interface }}"
@@ -51,4 +55,4 @@
template: template:
src: wg_client.j2 src: wg_client.j2
dest: "wg_clients/wg_{{ item }}.conf" dest: "wg_clients/wg_{{ item }}.conf"
with_items: "{{ groups['wg_clients'] | list }}" with_items: "{{ groups['wg_clients'] | list }}"