feat: add automatic template resolution for debian-13 alias

This commit is contained in:
Fredrick Amnehagen 2026-02-05 19:53:18 +01:00
parent 0dfaadab20
commit 42767fd8bc
2 changed files with 17 additions and 3 deletions

View file

@ -49,8 +49,8 @@ infra samba add-to-group "xmpp-users" "jdoe"
# List containers on a specific node
infra proxmox list-lxcs --node la-vmh-12
# Create a new container
infra proxmox create-lxc 12150 local:vztmpl/debian-13-standard_13.1-2_amd64.tar.zst "new-app" "10.32.70.100/16" "10.32.0.1" --node la-vmh-12
# Create a new container (CLI resolves "debian-13" automatically)
infra proxmox create-lxc 12150 debian-13 "new-app" "10.32.70.100/16" "10.32.0.1" --node la-vmh-12
```
### 3. Database (PostgreSQL)

View file

@ -25,12 +25,26 @@ class ProxmoxManager:
res = self.client.run(f"pct status {vmid}")
return res.stdout
def resolve_template(self, alias):
"""Resolves a template alias (e.g. 'debian-13') to the latest full path on the node"""
if alias == "debian-13":
# Search for debian-13 templates in all storages
res = self.client.run("pvesm list --content vztmpl | grep 'debian-13-standard' | sort -V | tail -n 1")
if res.returncode == 0 and res.stdout.strip():
# Extract first column (Volid)
return res.stdout.split()[0]
return alias # Fallback to original if no resolution
def create_lxc(self, vmid, template, hostname, ip, gateway, bridge="vmbr0", storage="local-zfs", password=None):
# Resolve template if it's an alias
full_template = self.resolve_template(template)
# Professional creation command with sane defaults
cmd = f"pct create {vmid} {template} --hostname {hostname} " \
cmd = f"pct create {vmid} {full_template} --hostname {hostname} " \
f"--net0 name=eth0,bridge={bridge},ip={ip},gw={gateway} " \
f"--storage {storage} --onboot 1"
if password:
cmd += f" --password {password}"