From 8188a7708a12eb25cc6836c0f3945ec0e07991a4 Mon Sep 17 00:00:00 2001 From: Vincent Brooks <38259624+V-Brooks@users.noreply.github.com> Date: Fri, 16 Feb 2024 10:58:30 -0600 Subject: [PATCH] Check if authorized_keys exist Deploys will fail without authorized_keys --- src/roles/base/tasks/main.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/roles/base/tasks/main.yml b/src/roles/base/tasks/main.yml index 54cfc7b5..2c66c751 100644 --- a/src/roles/base/tasks/main.yml +++ b/src/roles/base/tasks/main.yml @@ -18,8 +18,14 @@ mode: 0700 state: directory +- name: Check if meza-ansible authorized_keys exists + stat: + path: "{{ m_home }}/meza-ansible/.ssh/authorized_keys" + register: authorized_keys_result + - name: Copy meza-ansible authorized_keys to alt-meza-ansible shell: cp {{ m_home }}/meza-ansible/.ssh/authorized_keys {{ m_home }}/alt-meza-ansible/.ssh/authorized_keys + when: authorized_keys_result.stat.exists - name: Ensure user meza-ansible and alt-meza-ansible authorized_keys configured file: @@ -30,6 +36,7 @@ with_items: - meza-ansible - alt-meza-ansible + when: authorized_keys_result.stat.exists - name: Set authorized key for alt-meza-ansible authorized_key: