From 785b2ba8a4041025613e5bb8fd5041a003e64217 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Bourqui?= Date: Fri, 18 Oct 2019 18:40:47 +0200 Subject: [PATCH] Delete locally stored private key --- tasks/main.yml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tasks/main.yml b/tasks/main.yml index 99e20f7..c745c09 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -125,9 +125,25 @@ - wg-config notify: - restart wireguard - + - name: Start and enable WireGuard service service: name: "wg-quick@{{ wireguard_interface }}" state: started enabled: yes + +- name: Look for local private key + find: + paths: "{{ wireguard_cert_directory }}" + patterns: "*.private.key" + register: local_private_key_to_delete + delegate_to: localhost + run_once: true + +- name: Delete local private key + file: + path: "{{ item.path }}" + state: absent + with_items: "{{ local_private_key_to_delete.files }}" + delegate_to: localhost + run_once: true