From 0ec2bcda9f4a92d981141966f1862c2892e42349 Mon Sep 17 00:00:00 2001
From: Bo-Chun Chen <louistw@uab.edu>
Date: Fri, 27 Dec 2024 14:14:11 -0600
Subject: [PATCH] fix: add when condition to ssh_host_keys role

Follow the same approach in ssl_cert role, to avoid missing host key issue during deploy
---
 ansible/roles/ssh_host_keys/tasks/main.yml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/ansible/roles/ssh_host_keys/tasks/main.yml b/ansible/roles/ssh_host_keys/tasks/main.yml
index fa39838..59beb02 100644
--- a/ansible/roles/ssh_host_keys/tasks/main.yml
+++ b/ansible/roles/ssh_host_keys/tasks/main.yml
@@ -22,6 +22,7 @@
     aws_secret_key: "{{ LTS_SECRET_KEY }}"
   vars:
     ansible_python_interpreter: /usr/bin/python3
+  when: SSH_HOST_KEYS_S3_BUCKET | length > 0 and SSH_HOST_KEYS_S3_OBJECT | length > 0
 
 - name: Unpack SSH host keys to /etc/ssh
   ansible.builtin.unarchive:
@@ -31,6 +32,7 @@
     owner: root
     remote_src: yes
   become: true
+  when: SSH_HOST_KEYS_S3_BUCKET | length > 0 and SSH_HOST_KEYS_S3_OBJECT | length > 0
 
 - name: Remove the temporary folder after put in place
   ansible.builtin.file:
-- 
GitLab