From 02b114e0e6b6e7dc025f2d069ecc3498cb112b22 Mon Sep 17 00:00:00 2001 From: jon brookes Date: Tue, 14 Oct 2025 17:49:59 +0100 Subject: [PATCH] feat: add scripts for pre-flight checks and user input wait in k3s pipeline --- .../build-gcloud-k3s-pipeline-wait-dns.json | 56 +++++++++++++++++++ gcloud/tf/scripts/k3s-vm-startup.sh | 4 ++ gcloud/tf/scripts/wait_for_user_input_dns.sh | 11 ++++ 3 files changed, 71 insertions(+) create mode 100644 gcloud/tf/scripts/build-gcloud-k3s-pipeline-wait-dns.json create mode 100755 gcloud/tf/scripts/wait_for_user_input_dns.sh diff --git a/gcloud/tf/scripts/build-gcloud-k3s-pipeline-wait-dns.json b/gcloud/tf/scripts/build-gcloud-k3s-pipeline-wait-dns.json new file mode 100644 index 0000000..eeb5a5f --- /dev/null +++ b/gcloud/tf/scripts/build-gcloud-k3s-pipeline-wait-dns.json @@ -0,0 +1,56 @@ +[ + { + "name": "run pre-flight checks", + "function": "RunCommand", + "params": [ + "./gcloud/tf/scripts/pre-flight-checks.sh" + ], + "retryCount": 0, + "shouldAbort": true + }, + { + "name": "list gcloud infrastructure", + "function": "RunCommand", + "params": [ + "./gcloud/tf/scripts/list_gloud_infra.sh" + ], + "retryCount": 0, + "shouldAbort": true + }, + { + "name": "create tfvars", + "function": "RunCommand", + "params": [ + "./gcloud/tf/scripts/create_tfvars.sh" + ], + "retryCount": 0, + "shouldAbort": true + }, + { + "name": "run tofu", + "function": "RunCommand", + "params": [ + "./gcloud/tf/scripts/run_tofu.sh" + ], + "retryCount": 0, + "shouldAbort": true + }, + { + "name": "wait for user input to continue", + "function": "RunCommand", + "params": [ + "./gcloud/tf/scripts/wait_for_user_input_dns.sh" + ], + "retryCount": 0, + "shouldAbort": true + }, + { + "name": "copy .env to k3s-vm-1", + "function": "RunCommand", + "params": [ + "gcloud/tf/scripts/copy_env_to_first_node.sh" + ], + "retryCount": 0, + "shouldAbort": true + } +] \ No newline at end of file diff --git a/gcloud/tf/scripts/k3s-vm-startup.sh b/gcloud/tf/scripts/k3s-vm-startup.sh index 44793a1..6e2fcf9 100644 --- a/gcloud/tf/scripts/k3s-vm-startup.sh +++ b/gcloud/tf/scripts/k3s-vm-startup.sh @@ -1,5 +1,8 @@ #!/bin/bash +# Redirect all output to a log file for reliability +exec > /tmp/startup.log 2>&1 + INFCTL_GIT_REPO="https://codeberg.org/headshed/infctl-cli.git" INFCTL_GIT_REPO_BRANCH="main" INFCTL_INSTALL_DIR="/opt/src" @@ -123,6 +126,7 @@ source /opt/src/infctl-cli/.env if [[ "$INSTALL_FORGEJO" == "true" ]]; then # install forgejo using infctl # .... + export KUBECONFIG=/etc/rancher/k3s/k3s.yaml LOG_FORMAT=none infctl -f "${INFCTL_INSTALL_DIR}/infctl-cli/gcloud/tf/scripts/install-forgejo-pipeline.json" touch /etc/forgejo_was_installed diff --git a/gcloud/tf/scripts/wait_for_user_input_dns.sh b/gcloud/tf/scripts/wait_for_user_input_dns.sh new file mode 100755 index 0000000..a356571 --- /dev/null +++ b/gcloud/tf/scripts/wait_for_user_input_dns.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +echo "Please configure DNS using the IP address from the previous stage." +echo "you have 120 seconds." +for i in {120..1}; do + echo -ne "Time remaining: $i seconds\r" + sleep 1 +done +echo "" + +exit 0 \ No newline at end of file