From 634e9182c82a789304bbb7ac3b9f4cd2fea5d897 Mon Sep 17 00:00:00 2001 From: yohan <783b8c87@scimetis.net> Date: Sun, 29 Sep 2024 23:00:34 +0200 Subject: [PATCH] Do not change OpenVPN key everytime. --- roles/role_deploy_temp_openvpn-server/tasks/main.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/roles/role_deploy_temp_openvpn-server/tasks/main.yml b/roles/role_deploy_temp_openvpn-server/tasks/main.yml index ed96e59..dc1d0c9 100644 --- a/roles/role_deploy_temp_openvpn-server/tasks/main.yml +++ b/roles/role_deploy_temp_openvpn-server/tasks/main.yml @@ -14,11 +14,18 @@ changed_when: false become: true +- name: Check if key file already exists + stat: + path: /usr/local/docker-mounted-files/temp-openvpn-server/temp-p2p-shared.key + register: temp_p2p_shared_key + become: true + - name: Generate temporary P2P shared key ansible.builtin.command: cmd: "podman run --rm -i {{ private_registry_domain }}/openvpn:176450680a --genkey secret" register: openvpn_genkey_result become: true + when: not temp_p2p_shared_key.stat.exists - name: Template key file ansible.builtin.template: @@ -33,6 +40,7 @@ - temp-p2p-shared.key vars: temp_p2p_shared_key: "{{ openvpn_genkey_result.stdout }}" + when: not temp_p2p_shared_key.stat.exists - name: Create temp-openvpn-server container containers.podman.podman_container: