30 lines
816 B
YAML
30 lines
816 B
YAML
---
|
|
- name: Cleanup expired VPN configuration
|
|
hosts: vpn_servers
|
|
become: yes
|
|
vars:
|
|
client_dir: /etc/wireguard/clients
|
|
wg_interface: wg0
|
|
|
|
tasks:
|
|
- name: Debug subscription ID
|
|
debug:
|
|
msg: "Cleaning up subscription ID: {{ subscription_id }}"
|
|
|
|
- name: Remove client configuration directory
|
|
file:
|
|
path: "{{ client_dir }}/{{ subscription_id }}"
|
|
state: absent
|
|
|
|
- name: Remove client from server config
|
|
blockinfile:
|
|
path: "/etc/wireguard/{{ wg_interface }}.conf"
|
|
marker: "# {mark} ANSIBLE MANAGED BLOCK FOR {{ subscription_id }}"
|
|
state: absent
|
|
notify: restart wireguard
|
|
|
|
handlers:
|
|
- name: restart wireguard
|
|
service:
|
|
name: "wg-quick@{{ wg_interface }}"
|
|
state: restarted |