Proxmox Cloud Image Tool
Tool untuk membuat template di Proxmox menggunakan cloud image (Ubuntu, Debian, CentOS, dll) dengan Golang.
Features
- Download cloud image dari URL
- Customize image (resize disk, inject SSH key)
- Otomatis create template di Proxmox
- Support konfigurasi via CLI flags atau YAML file
- Progress bar untuk download
- QEMU Guest Agent support (auto-enable)
- Firewall configuration (enable/disable + custom rules)
- Batch mode untuk create multiple templates sekaligus
Requirements
- Go 1.19+
- SSH access ke Proxmox host
qemu-imgdanvirt-customize(libguestfs-tools)
Install dependencies di Ubuntu/Debian:
sudo apt install qemu-utils libguestfs-tools
Installation
Quick Install (Recommended):
git clone <repo-url>
cd cloud-image
sudo ./install.sh
Installer akan otomatis:
- Install dependencies (qemu-utils, libguestfs-tools)
- Build binary
- Install ke
/usr/local/bin
Manual Build:
git clone <repo-url>
cd cloud-image
go build -o proxmox-cloud-image
sudo cp proxmox-cloud-image /usr/local/bin/
sudo chmod +x /usr/local/bin/proxmox-cloud-image
Uninstall:
cd cloud-image
sudo ./uninstall.sh
Setelah install, bisa langsung dipanggil dari mana aja:
proxmox-cloud-image -h
Usage
Menggunakan CLI flags:
proxmox-cloud-image \
-image-url "https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img" \
-vm-name "ubuntu-template" \
-vm-id 9000 \
-proxmox-host "192.168.1.100" \
-proxmox-user "root@pam" \
-storage "local-lvm" \
-memory 2048 \
-cores 2 \
-disk-size "20G" \
-bridge "vmbr0" \
-ssh-key "/root/.ssh/id_rsa.pub" \
-guest-agent \
-firewall
Auto-find VM ID (mulai dari 10000):
proxmox-cloud-image \
-image-url "https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img" \
-vm-name "ubuntu-template" \
-proxmox-host "192.168.1.100" \
-guest-agent
Dengan VLAN:
proxmox-cloud-image \
-image-url "https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img" \
-vm-name "ubuntu-template" \
-vm-id 9000 \
-proxmox-host "192.168.1.100" \
-bridge "vmbr0" \
-vlan-tag 100 \
-guest-agent \
-firewall
Menggunakan config file:
proxmox-cloud-image -config config.yaml
Contoh config.yaml:
image_url: "https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img"
vm_name: "ubuntu-template"
vm_id: 0
storage: "local-lvm"
memory: 2048
cores: 2
disk_size: "20G"
bridge: "vmbr0"
vlan_tag: 100
ssh_key: "/root/.ssh/id_rsa.pub"
proxmox_host: "192.168.1.100"
proxmox_user: "root@pam"
proxmox_pass: ""
guest_agent: true
firewall: true
firewall_rules:
- type: in
action: accept
protocol: tcp
dport: "22"
comment: "SSH"
- type: in
action: accept
protocol: tcp
dport: "80,443"
comment: "HTTP/HTTPS"
Batch mode (multiple templates):
Buat file batch (contoh: batch.txt) dengan list config files:
# Ubuntu templates
configs/ubuntu-22.04.yaml
configs/ubuntu-20.04.yaml
# Debian templates
configs/debian-12.yaml
configs/debian-11.yaml
Jalankan batch:
proxmox-cloud-image -batch batch.txt
Features:
- Process multiple config files sekaligus
- Max 3 concurrent jobs (parallel)
- Auto-skip lines yang kosong atau comment (#)
- Summary report di akhir
Cloud Image URLs
Ubuntu
- Ubuntu 22.04 (Jammy):
https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img - Ubuntu 20.04 (Focal):
https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img
Debian
- Debian 12 (Bookworm):
https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-generic-amd64.qcow2 - Debian 11 (Bullseye):
https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-generic-amd64.qcow2
CentOS Stream
- CentOS Stream 9:
https://cloud.centos.org/centos/9-stream/x86_64/images/CentOS-Stream-GenericCloud-9-latest.x86_64.qcow2
Flags
| Flag | Default | Description |
|---|---|---|
-config |
- | Path ke config file (YAML) |
-image-url |
- | URL cloud image (required) |
-vm-name |
cloud-vm | Nama template |
-vm-id |
0 | Template ID (0 = auto-find dari 10000+) |
-storage |
auto-detect | Nama storage Proxmox (auto-detect jika kosong) |
-memory |
2048 | Memory dalam MB |
-cores |
2 | Jumlah CPU cores |
-disk-size |
20G | Ukuran disk |
-bridge |
vmbr0 | Network bridge |
-vlan-tag |
0 | VLAN tag (0 = no VLAN) |
-guest-agent |
false | Enable QEMU guest agent |
-firewall |
false | Enable firewall |
-ssh-key |
- | Path ke SSH public key |
-proxmox-host |
- | IP/hostname Proxmox (required) |
-proxmox-user |
root@pam | Proxmox user |
-proxmox-pass |
- | Proxmox password |
-list-storage |
- | List semua storage yang tersedia |
-ls |
- | Shorthand untuk -list-storage |
How It Works
- Download cloud image dari URL yang diberikan
- Customize image (resize, inject SSH key jika ada)
- Upload image ke Proxmox host via SCP
- Create VM menggunakan
qmcommands - Import disk dan configure VM
- Setup cloud-init
- Enable QEMU Guest Agent (jika di-enable)
- Enable Proxmox firewall (jika di-enable)
- Configure firewall rules (jika ada rules yang di-define)
- Convert VM menjadi template dengan
qm template
QEMU Guest Agent
QEMU Guest Agent adalah service yang berjalan di guest OS untuk:
- IP address discovery
- Graceful shutdown/reboot
- File system freeze/thaw
- Time synchronization
Enable dengan flag -guest-agent atau di config file:
guest_agent: true
Proxmox Firewall
Proxmox firewall bisa di-enable untuk template dengan flag -firewall atau di config file:
firewall: true
Firewall Rules
Kamu juga bisa define firewall rules langsung di config file:
firewall: true
firewall_rules:
- type: in
action: accept
protocol: tcp
dport: "22"
comment: "SSH"
- type: in
action: accept
protocol: tcp
dport: "80,443"
comment: "HTTP/HTTPS"
- type: in
action: accept
protocol: icmp
comment: "ICMP/Ping"
- type: in
action: drop
comment: "Drop all other incoming"
Firewall Rule Fields:
type:in(incoming) atauout(outgoing)action:accept,drop, ataurejectprotocol:tcp,udp,icmp, dll (optional)dport: destination port atau port range, contoh:22,80,443,8000:9000(optional)sport: source port (optional)source: source IP/CIDR, contoh:192.168.1.0/24(optional)dest: destination IP/CIDR (optional)comment: komentar untuk rule (optional)
Rules akan ditulis ke /etc/pve/firewall/<vmid>.fw di Proxmox host.
Firewall akan di-enable di network interface VM.
Clone Template
Setelah template dibuat, kamu bisa clone untuk membuat VM baru:
qm clone 9000 100 --name my-vm --full
qm set 100 --ipconfig0 ip=192.168.1.100/24,gw=192.168.1.1
qm set 100 --sshkeys /root/.ssh/id_rsa.pub
qm start 100
Notes
- Tool ini menggunakan SSH untuk koneksi ke Proxmox
- Pastikan SSH key sudah di-setup untuk passwordless login
- Image akan di-download ke
/tmpdan di-upload ke Proxmox - Template tidak bisa di-start, harus di-clone dulu
- QEMU Guest Agent akan otomatis ter-install di guest OS yang support
License
MIT