Fix sandbox provisioning failure due to missing LIMA_CIDATA_USER

The provision script relied on LIMA_CIDATA_USER being set in the
environment, but during cloud-init this variable is not exported — it
only exists in /mnt/lima-cidata/lima.env. The file cannot be sourced
directly because values like LIMA_CIDATA_COMMENT contain unquoted
spaces, so we extract LIMA_CIDATA_USER with sed instead.

Also ensure HOME is set for root's go install commands and explicitly
set PATH when running make as the Lima user via su, since profile.d
scripts may not be loaded during cloud-init provisioning.

Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
Bryan Frimin
2026-03-18 19:50:55 +01:00
parent 9fd3473147
commit f3aa0dea36

View File

@@ -4,6 +4,11 @@
set -euo pipefail
# Read Lima user from cidata (values are unquoted so we cannot source the file
# directly — LIMA_CIDATA_COMMENT may contain spaces).
LIMA_CIDATA_USER="$(sed -n 's/^LIMA_CIDATA_USER=//p' /mnt/lima-cidata/lima.env)"
export LIMA_CIDATA_USER
export DEBIAN_FRONTEND=noninteractive
GO_VERSION="1.26.1"
@@ -64,6 +69,7 @@ GOEOF
chmod +x /etc/profile.d/go.sh
export PATH="/usr/local/go/bin:$PATH"
export HOME="${HOME:-/root}"
GOBIN=/usr/local/bin /usr/local/go/bin/go install "gotest.tools/gotestsum@${GOTESTSUM_VERSION}"
GOBIN=/usr/local/bin /usr/local/go/bin/go install "github.com/golangci/golangci-lint/v2/cmd/golangci-lint@${GOLANGCI_LINT_VERSION}"
@@ -90,7 +96,7 @@ chown -R "${LIMA_USER}:${LIMA_USER}" "${LIMA_HOME}/.parallel"
# Generate sandbox-specific probod config and frontend .env files
VM_IP=$(ip -4 -j addr show dev lima0 | jq -r '.[0].addr_info[0].local')
su - "${LIMA_USER}" -c "cd /workspace && make bin/probod-bootstrap"
su - "${LIMA_USER}" -c "export PATH=/usr/local/go/bin:\$HOME/go/bin:\$PATH && cd /workspace && make bin/probod-bootstrap"
mkdir -p /etc/probod