Add support for local image files (URL or local path)

This commit is contained in:
2025-11-18 16:00:29 +07:00
parent 5690f50cfc
commit 651ca6ecd3
3 changed files with 162 additions and 7 deletions

View File

@@ -4,7 +4,7 @@ Tool untuk membuat **template** di Proxmox menggunakan cloud image (Ubuntu, Debi
## Features
- Download cloud image dari URL
- Download cloud image dari URL **atau gunakan local file**
- Customize image (resize disk, inject SSH key)
- Otomatis create template di Proxmox
- Support konfigurasi via CLI flags atau YAML file
@@ -120,7 +120,7 @@ proxmox-cloud-image -h
## Usage
### Menggunakan CLI flags:
### Menggunakan URL (download):
```bash
proxmox-cloud-image \
@@ -139,6 +139,18 @@ proxmox-cloud-image \
-firewall
```
### Menggunakan local file:
```bash
proxmox-cloud-image \
-image-url "/path/to/ubuntu-22.04-server-cloudimg-amd64.img" \
-vm-name "ubuntu-template" \
-vm-id 9000 \
-proxmox-host "192.168.1.100" \
-storage "local-lvm" \
-guest-agent
```
### Auto-find VM ID (mulai dari 10000):
```bash
@@ -169,7 +181,7 @@ proxmox-cloud-image \
proxmox-cloud-image -config config.yaml
```
Contoh `config.yaml`:
Contoh `config.yaml` dengan URL:
```yaml
image_url: "https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img"
vm_name: "ubuntu-template"
@@ -199,6 +211,23 @@ firewall_rules:
comment: "HTTP/HTTPS"
```
Contoh `config.yaml` dengan local file:
```yaml
image_url: "/home/user/images/ubuntu-22.04-server-cloudimg-amd64.img"
vm_name: "ubuntu-template"
vm_id: 0
storage: "local-lvm"
memory: 2048
cores: 2
disk_size: "20G"
bridge: "vmbr0"
ssh_key: "/root/.ssh/id_rsa.pub"
proxmox_host: "192.168.1.100"
proxmox_user: "root@pam"
guest_agent: true
firewall: false
```
### Batch mode (multiple templates):
Buat file batch (contoh: `batch.txt`) dengan list config files:
@@ -261,7 +290,7 @@ proxmox-cloud-image -batch batch.txt
## How It Works
1. Download cloud image dari URL yang diberikan
1. **Prepare image** (download dari URL atau copy dari local file)
2. Customize image:
- Resize disk (jika di-specify)
- Inject SSH key (jika ada)