From 48e7362014faef7c771e214606bb44949c9d6dc7 Mon Sep 17 00:00:00 2001 From: Bas Meijer Date: Wed, 27 Nov 2024 11:44:20 +0100 Subject: [PATCH] Only install github key when found --- roles/api/tasks/credentials.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/roles/api/tasks/credentials.yml b/roles/api/tasks/credentials.yml index f2ba15f..c11217d 100644 --- a/roles/api/tasks/credentials.yml +++ b/roles/api/tasks/credentials.yml @@ -45,7 +45,7 @@ when: - "semaphore_keystores.json | selectattr('name', 'equalto', 'Controller-ssh-key') | length == 0" - - name: "Semaphore | Read ssh key from system" + - name: "Read ssh key from system" delegate_to: localhost connection: local become: false @@ -53,6 +53,7 @@ ansible.builtin.slurp: path: "{{ my_github_key }}" register: "ssh_key_github" + failed_when: false - name: "Create SSH key for GitHub" changed_when: "semaphore_key_github_created.status == 204" @@ -78,4 +79,5 @@ timeout: 5 register: semaphore_key_github_created when: + - "'file not found' not in ssh_key_github.msg" - "semaphore_keystores.json | selectattr('name', 'equalto', 'github-ssh-key') | length == 0"