mirror of
https://github.com/GoodOlClint/PSProxmoxVE.git
synced 2026-09-04 03:05:32 +00:00
ci: opt-in dist-upgrade and reboot for the currency lane
This commit is contained in:
@@ -2,16 +2,22 @@
|
||||
# Prepares the test environment on the nested PVE node.
|
||||
# Only performs operations that have no PVE API equivalent.
|
||||
#
|
||||
# Usage: prepare-test-environment.sh <nested-pve-ip> <root-password>
|
||||
# Usage: prepare-test-environment.sh <nested-pve-ip> <root-password> [dist-upgrade] [pkg-out]
|
||||
#
|
||||
# Operations:
|
||||
# - Optionally dist-upgrade the node, record its package set, and reboot
|
||||
# (currency lane only; off unless <dist-upgrade> is 1)
|
||||
# - Enable snippets+import content types on local storage (pvesm set)
|
||||
# - Upload cloud-init user-data snippet (SCP — no snippet upload API)
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
NESTED_IP="${1:?Usage: prepare-test-environment.sh <ip> <password>}"
|
||||
NESTED_IP="${1:?Usage: prepare-test-environment.sh <ip> <password> [dist-upgrade] [pkg-out]}"
|
||||
ROOT_PASS="$2"
|
||||
DIST_UPGRADE="${3:-0}"
|
||||
PKG_OUT="${4:-}"
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
SSH_OPTS="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR"
|
||||
SSH_CMD="sshpass -p ${ROOT_PASS} ssh ${SSH_OPTS} root@${NESTED_IP}"
|
||||
@@ -19,6 +25,32 @@ SCP_CMD="sshpass -p ${ROOT_PASS} scp ${SSH_OPTS}"
|
||||
|
||||
echo "=== Preparing test environment on ${NESTED_IP} ==="
|
||||
|
||||
if [[ "${DIST_UPGRADE}" == "1" ]]; then
|
||||
echo "Running dist-upgrade (currency lane)..."
|
||||
${SSH_CMD} "DEBIAN_FRONTEND=noninteractive apt-get update -qq && \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get -y \
|
||||
-o Dpkg::Options::=--force-confold \
|
||||
-o Dpkg::Options::=--force-confdef \
|
||||
dist-upgrade"
|
||||
|
||||
if [[ -n "${PKG_OUT}" ]]; then
|
||||
echo "Recording package set to ${PKG_OUT}..."
|
||||
${SSH_CMD} "dpkg-query -W -f='\${binary:Package}\t\${Version}\n' | sort" > "${PKG_OUT}"
|
||||
fi
|
||||
|
||||
# A PVE dist-upgrade pulls proxmox-kernel-*; without a reboot the node runs
|
||||
# new userspace on the old kernel. Reboot unconditionally rather than
|
||||
# testing /var/run/reboot-required — that file comes from
|
||||
# update-notifier-common, which is not guaranteed on a PVE node.
|
||||
echo "Rebooting after dist-upgrade..."
|
||||
${SSH_CMD} "systemctl reboot" || true
|
||||
|
||||
# The API stays up for a few seconds after the reboot is issued, so polling
|
||||
# immediately would match the pre-reboot node and return at once.
|
||||
sleep 30
|
||||
bash "${SCRIPT_DIR}/wait-for-api.sh" "${NESTED_IP}" 8006 600
|
||||
fi
|
||||
|
||||
# Enable snippets and import content types on local storage
|
||||
echo "Configuring local storage content types..."
|
||||
${SSH_CMD} "mkdir -p /var/lib/vz/snippets && pvesm set local --content images,iso,vztmpl,snippets,import"
|
||||
|
||||
Reference in New Issue
Block a user