Compare commits

...

2 Commits

Author SHA1 Message Date
juvenal.diaz bcf45c6e8b Make Pimox template replacement rerun provisioning
Homelab Main / validate (push) Waiting to run Details
Homelab Main / deploy (push) Blocked by required conditions Details
2026-09-25 13:48:06 -06:00
juvenal.diaz 0b36e21a38 Use grep for Pimox template showcmd validation 2026-09-25 13:39:14 -06:00
1 changed files with 16 additions and 17 deletions

View File

@ -133,8 +133,9 @@ resource "null_resource" "pimox_template_vm_create" {
pimox_user = var.pimox_user
ssh_key_path = var.pimox_ssh_key_path
qm_bin = var.pimox_qm_bin
builder_version = "6"
builder_version = "7"
config_hash = local.config_hash
replace_existing = tostring(var.pimox_template_replace_existing)
vmid = tostring(var.pimox_template_vmid)
name = var.pimox_template_name
cores = tostring(var.pimox_template_cores)
@ -195,15 +196,13 @@ start_vm() {
trap 'rm -f "$start_script"' 0
sudo "$qm_cmd" showcmd "$vmid" --pretty >"$start_script"
if ! awk -v vmid="$vmid" '
NR == 1 && ($1 == "/usr/bin/kvm" || $1 ~ /qemu-system-aarch64$/) { kvm = 1 }
$1 == "-id" && $2 == vmid { id = 1 }
END { exit (kvm && id) ? 0 : 1 }
' "$start_script"; then
if ! { grep -Fq -- '/usr/bin/kvm' "$start_script" || grep -Fq -- 'qemu-system-aarch64' "$start_script"; } ||
! grep -Fq -- "-id $vmid" "$start_script"; then
echo "qm showcmd for VM $vmid did not produce the expected KVM command" >&2
sed 's/^/ showcmd: /' "$start_script" >&2
exit 1
fi
smp_count="$(awk '$1 == "-smp" { count++ } END { print count + 0 }' "$start_script")"
smp_count="$(grep -c '^[[:space:]]*-smp[[:space:]]' "$start_script" || true)"
if [ "$smp_count" -ne 1 ]; then
echo "Expected one native -smp argument for VM $vmid, found $smp_count. Remove stale qm args before starting." >&2
exit 1