File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,16 @@ echo "[3/4] Uploading systemd template..."
3434ssh -i " ${SSH_KEY_LOCAL} " " ${JUMP_USER} @${JUMP_HOST} " " mkdir -p ${REMOTE_DIR} /templates"
3535scp -i " ${SSH_KEY_LOCAL} " " ${TEMPLATE_LOCAL} " " ${JUMP_USER} @${JUMP_HOST} :${TEMPLATE_REMOTE} "
3636
37+ # === STEP 3.5: Preload known_hosts in the jumpbox to avoid host key verification ===
38+ echo " [3.5/4] Adding backend VM keys to known_hosts on the jumpbox..."
39+ ssh -i " ${SSH_KEY_LOCAL} " " ${JUMP_USER} @${JUMP_HOST} " bash << 'EOF '
40+ set -e
41+ # Parse inventory to get IPs and add them to known_hosts
42+ for ip in $(grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}' inventory.ini); do
43+ ssh-keyscan -H "$ip" >> ~/.ssh/known_hosts 2>/dev/null || true
44+ done
45+ EOF
46+
3747# === STEP 4: Execute playbook remotely ===
3848echo " [4/4] Executing playbook from the jump host..."
3949ssh -i " ${SSH_KEY_LOCAL} " " ${JUMP_USER} @${JUMP_HOST} " << EOF
You can’t perform that action at this time.
0 commit comments