From 43b4441f14d426ec541ddf530992f3121f04f266 Mon Sep 17 00:00:00 2001 From: modem7 Date: Sat, 26 Sep 2026 01:07:33 +0100 Subject: [PATCH 01/11] create-ubuntu-cloud-template: fix cloud-init snippet, failure cleanup and profile bugs Attach the snippet as vendor-data instead of user-data, so clones keep the Proxmox user, password, SSH keys and hostname. Run cleanup on every failure (set -E plus an EXIT trap). Keep SNIPPETS_STOR and the template name from the profile. Keep safety flags command-line only. Use import-from for the disk, check VM IDs cluster-wide, validate SSH keys, merge the virt-customize calls, and restructure comments and help for readability. --- .../create-ubuntu-cloud-template.sh | 1890 ++++++++--------- 1 file changed, 912 insertions(+), 978 deletions(-) diff --git a/Bash/Proxmox Scripts/create-ubuntu-cloud-template.sh b/Bash/Proxmox Scripts/create-ubuntu-cloud-template.sh index 83c6186..117e8e6 100755 --- a/Bash/Proxmox Scripts/create-ubuntu-cloud-template.sh +++ b/Bash/Proxmox Scripts/create-ubuntu-cloud-template.sh @@ -1,104 +1,122 @@ #!/bin/bash # ============================================================================= -# Proxmox Ubuntu Cloud-Init Template Creator +# Proxmox Ubuntu Cloud-Init Template Creator # ============================================================================= -# Creates a cloud-init ready Ubuntu VM template on Proxmox VE. -# Supports ZFS (raw), LVM-thin (raw), and directory (qcow2) storage backends. # -# Usage: -# ./create-ubuntu-cloud-template.sh [OPTIONS] +# WHAT IT DOES +# Builds a ready-to-clone Ubuntu VM template on a Proxmox VE host. +# 1. Downloads the official Ubuntu cloud image (SHA256 verified). +# 2. Bakes in the qemu-guest-agent plus any extra packages you choose. +# 3. Creates the VM, attaches the disk + cloud-init drive. +# 4. Optionally converts it to a template. # -# Run with --help to see all available options and examples. +# REQUIREMENTS +# - Run as root on a Proxmox VE host. +# - Internet access (cloud-images.ubuntu.com, optionally github.com). +# - Missing host packages are offered for install automatically. # -# Quick start: -# First run: answer the prompts, save a named profile at the end. -# Repeat run: ./create-ubuntu-cloud-template.sh --config .conf -# Automated: ./create-ubuntu-cloud-template.sh --config .conf \ -# --unattended --vmid [--template] [--force-overwrite \ -# --i-know-what-i-am-doing] +# QUICK START +# First run ./create-ubuntu-cloud-template.sh +# Answer the prompts. Save a profile when asked. # -# VM ID selection: -# --auto-vmid alone: finds the next free ID from 100 upwards. -# --vmid --auto-vmid: tries first, then increments from there -# if taken. Use this to control which range your -# templates live in (e.g. --vmid 52000 --auto-vmid -# keeps templates in the 52000+ range). -# --vmid alone: uses exactly , fails if already taken. +# Re-run ./create-ubuntu-cloud-template.sh --config .conf +# +# Automated ./create-ubuntu-cloud-template.sh --config .conf \ +# --unattended --vmid 52000 --auto-vmid --template +# +# All options ./create-ubuntu-cloud-template.sh --help +# +# VM ID CHEAT SHEET +# --vmid 52001 Use exactly 52001. Stop if taken. +# --auto-vmid Next free ID, starting at 100. +# --vmid 52000 --auto-vmid Next free ID, starting at 52000. +# (Keeps templates in their own range.) +# +# FILES IT CREATES +#