Add scripts for automated Ubuntu VM creation using cloud images and cloud-init - #278
Conversation
WalkthroughA new Bash script automates Proxmox VM provisioning using Ubuntu cloud images with cloud-init configuration. The script downloads verified images, generates cloud-init user-data, and creates fully configured VMs. Configuration variables in an existing script are updated, and documentation is reorganized to prioritize the cloud-init deployment method. Changes
Sequence DiagramsequenceDiagram
actor User
participant Script as create-ubuntu-<br/>cloud-vm.sh
participant HTTP as Ubuntu<br/>Cloud Server
participant FS as Local<br/>Filesystem
participant Proxmox as Proxmox<br/>qm Commands
participant VM as Ubuntu<br/>Cloud-init VM
User->>Script: Execute with --vmid, --vmname
Script->>Script: Parse arguments & validate
rect rgba(100, 150, 255, 0.5)
Note over Script,HTTP: Download & Verify Image
Script->>HTTP: Request cloud image
HTTP-->>Script: Image data
Script->>HTTP: Request SHA256SUMS
HTTP-->>Script: Checksums
Script->>FS: Write & verify image
FS-->>Script: Verification result
end
alt Download-only mode
Script-->>User: Image ready
else VM Creation
rect rgba(100, 200, 100, 0.5)
Note over Script,FS: Generate Cloud-init Config
Script->>Script: get_authorized_keys()
Script->>FS: Write user-data config
FS-->>Script: Config file path
end
rect rgba(200, 150, 100, 0.5)
Note over Script,Proxmox: Create & Configure VM
Script->>Proxmox: qm create (disk, CPU, memory)
Proxmox-->>Script: VM created
Script->>Proxmox: qm set (network, boot order)
Proxmox-->>Script: VM configured
Script->>Proxmox: Set cicustom (cloud-init)
Proxmox-->>Script: Cloud-init linked
Script->>Proxmox: qm start
Proxmox->>VM: Boot VM
VM->>VM: Apply cloud-init config
VM-->>User: Ready
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@proxmox/create-ubuntu-cloud-vm.sh`:
- Around line 18-20: The comment above readonly PASSWORD_HASH incorrectly states
SHA-512 while the hash uses the $5$ (SHA-256) prefix; either update the comment
to reflect SHA-256 (change the --method note to SHA-256) or regenerate the
PASSWORD_HASH using SHA-512 (ensuring the new hash has a $6$ prefix) and replace
the current value, and keep the shellcheck disable comment as-is.
🧹 Nitpick comments (1)
proxmox/create-ubuntu-cloud-vm.sh (1)
87-88: Emptyssh_authorized_keysproduces valid but potentially unexpected YAML.If
~/.ssh/authorized_keysis empty or missing,get_authorized_keysreturns nothing, resulting in:ssh_authorized_keys: packages:This is technically valid YAML (empty sequence), but consider adding a comment or conditional to make the intent clearer, or omit the key entirely when there are no keys.
Optional: Conditional ssh_authorized_keys block
+get_ssh_authorized_keys_block() { + local AUTHORIZED_KEYS_FILE=~/.ssh/authorized_keys + if [ -s "$AUTHORIZED_KEYS_FILE" ]; then + echo " ssh_authorized_keys:" + sed 's/^/ - /' "$AUTHORIZED_KEYS_FILE" + fi +}Then in the heredoc, replace lines 87-88 with:
$(get_ssh_authorized_keys_block)
Summary by CodeRabbit
New Features
Documentation
Chores