Skip to content

Commit

Permalink
Check if authorized_keys exist
Browse files Browse the repository at this point in the history
Deploys will fail without authorized_keys
  • Loading branch information
V-Brooks authored Feb 16, 2024
1 parent 61e1fe5 commit 8188a77
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/roles/base/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit 8188a77

Please sign in to comment.