From 78eaf7ec02b7f648a33ff492ad84ee1cada7cf02 Mon Sep 17 00:00:00 2001 From: Matej Focko Date: Sat, 12 Mar 2022 23:25:23 +0100 Subject: [PATCH] feat(ssh): do not recreate key if exists Fixes #37 Signed-off-by: Matej Focko --- playbooks/roles/ssh/tasks/main.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/playbooks/roles/ssh/tasks/main.yml b/playbooks/roles/ssh/tasks/main.yml index 7e53429..ca62b19 100644 --- a/playbooks/roles/ssh/tasks/main.yml +++ b/playbooks/roles/ssh/tasks/main.yml @@ -1,10 +1,16 @@ --- +- name: Check if SSH key exists + stat: + path: ~/.ssh/id_ed25519 + register: ssh_key + - name: Generate SSH key user: name: mfocko generate_ssh_key: yes ssh_key_type: ed25519 ssh_key_comment: "$HOSTNAME-{{ ansible_facts['distribution'] }}" + when: not ssh_key.stat.exists - name: Install SSH config template: