Initial commit: Proxmox cloud image template tool
This commit is contained in:
172
README.md
Normal file
172
README.md
Normal file
@@ -0,0 +1,172 @@
|
||||
# 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
|
||||
|
||||
## Requirements
|
||||
|
||||
- Go 1.19+
|
||||
- SSH access ke Proxmox host
|
||||
- `qemu-img` dan `virt-customize` (libguestfs-tools)
|
||||
|
||||
Install dependencies di Ubuntu/Debian:
|
||||
```bash
|
||||
sudo apt install qemu-utils libguestfs-tools
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
### Build from source:
|
||||
|
||||
```bash
|
||||
git clone <repo-url>
|
||||
cd cloud-image
|
||||
go build -o proxmox-cloud-image
|
||||
```
|
||||
|
||||
### Install globally (Linux):
|
||||
|
||||
```bash
|
||||
sudo cp proxmox-cloud-image /usr/local/bin/
|
||||
sudo chmod +x /usr/local/bin/proxmox-cloud-image
|
||||
```
|
||||
|
||||
Setelah install, bisa langsung dipanggil dari mana aja:
|
||||
```bash
|
||||
proxmox-cloud-image -h
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### Menggunakan CLI flags:
|
||||
|
||||
```bash
|
||||
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"
|
||||
```
|
||||
|
||||
### Auto-find VM ID (mulai dari 10000):
|
||||
|
||||
```bash
|
||||
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"
|
||||
```
|
||||
|
||||
Kalo `-vm-id` tidak diisi atau diset `0`, tool akan otomatis cari VM ID kosong mulai dari 10000.
|
||||
|
||||
### Dengan VLAN:
|
||||
|
||||
```bash
|
||||
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
|
||||
```
|
||||
|
||||
### Menggunakan config file:
|
||||
|
||||
```bash
|
||||
proxmox-cloud-image -config config.yaml
|
||||
```
|
||||
|
||||
Contoh `config.yaml`:
|
||||
```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"
|
||||
```
|
||||
|
||||
## 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` | local-lvm | Nama storage Proxmox |
|
||||
| `-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) |
|
||||
| `-ssh-key` | - | Path ke SSH public key |
|
||||
| `-proxmox-host` | - | IP/hostname Proxmox (required) |
|
||||
| `-proxmox-user` | root@pam | Proxmox user |
|
||||
| `-proxmox-pass` | - | Proxmox password |
|
||||
|
||||
## How It Works
|
||||
|
||||
1. Download cloud image dari URL yang diberikan
|
||||
2. Customize image (resize, inject SSH key jika ada)
|
||||
3. Upload image ke Proxmox host via SCP
|
||||
4. Create VM menggunakan `qm` commands
|
||||
5. Import disk dan configure VM
|
||||
6. Setup cloud-init
|
||||
7. **Convert VM menjadi template** dengan `qm template`
|
||||
|
||||
## Clone Template
|
||||
|
||||
Setelah template dibuat, kamu bisa clone untuk membuat VM baru:
|
||||
|
||||
```bash
|
||||
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 `/tmp` dan di-upload ke Proxmox
|
||||
- Template tidak bisa di-start, harus di-clone dulu
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
Reference in New Issue
Block a user