Ubuntu VM: check for a snippets storage before building a static-IP VM (#18347)

Ubuntu 26.04 needs the MAC-matched network snippet, and without a storage for snippets the run failed only after the VM was created. It now stops before downloading the image.
This commit is contained in:
CanbiZ (MickLesk)
2026-10-31 22:13:45 +01:00
committed by GitHub
parent e65ff59c97
commit bcb72dc9b8
+6
View File
@@ -130,6 +130,12 @@ vm_prompt_cloud_init "ubuntu"
if [ "$USE_CLOUD_INIT" != "yes" ]; then
msg_warn "Without Cloud-Init this Ubuntu image gets no network configuration or credentials; configure them in the guest yourself."
fi
if [[ "$USE_CLOUD_INIT" == "yes" && "${CLOUDINIT_NETWORK_MODE:-dhcp}" == "static" && -z "${CLOUDINIT_SNIPPET_STORAGE:-}" ]] &&
! pvesm status -content snippets 2>/dev/null | awk 'NR > 1 && $3 == "active" {found = 1} END {exit !found}'; then
msg_error "A static IP needs a storage with 'snippets' content, and none is active"
msg_warn "Enable Snippets under Datacenter > Storage on a directory storage, or choose DHCP"
exit 1
fi
post_to_api_vm
vm_select_storage "$HN"
vm_define_disk_references 2