Skip to content

Guide

Proxmox VE cloud-init VM templates, kept up to date with oic-sync

Get one cloud-init VM template per image on your Proxmox VE node, ready for qm clone. Each new image version becomes a new template at the next run. Clones you already made are never touched.

What it does

oic-sync reads the catalog index, verifies the cosign signature of each image, and turns each new version into a VM template. The newest template is named after the image (debian-13); older ones are renamed, tagged as retired, then rotated out.

  • Runs on the node, as root (like pveam), through the local API with pvesh: no API token, nothing to configure.
  • No local state, idempotent: when everything is up to date, a run changes nothing. A daily timer is enough.
  • Tested on Proxmox VE 9.2. VM templates only, no LXC.

Status: alpha. License: Apache-2.0. The same tool also keeps OpenStack Glance images up to date.

Install

On the node, as root, from PyPI. No extra is needed for Proxmox VE.

Proxmox VE node
apt install pipx
pipx install oic-sync

Downloads go to a file storage with the import content type. Enable it once, keeping the content types the storage already has:

bash
# List the content types the storage already has, plus import
pvesm set local --content iso,vztmpl,backup,import

Both storages are checked before anything is created: a missing or inactive storage, or a missing content type, stops the run before any VM exists.

First run

Start read only with status and --dry-run, then sync.

bash
# Compare the node templates with the index (read only)
oic-sync proxmox status
# Show what a sync would do (read only, signatures verified)
oic-sync proxmox sync --image debian-13 --image ubuntu-24.04 --dry-run
# Do it: templates from VMID 9000, disks on local-lvm
oic-sync proxmox sync --image debian-13 --image ubuntu-24.04 --vmid-base 9000 --disk-storage local-lvm
# Remove versions beyond --keep that no linked clone uses
oic-sync proxmox sync --image debian-13 --keep 2 --delete

oic-sync list shows the image IDs of the index. proxmox status --check exits with 1 when an image is not up to date, for monitoring, and --json gives machine-readable output.

Use a template

Cloud images are small: grow the disk before the first boot. A linked clone, made with --full 0, protects its template from deletion by the rotation.

bash
qm clone 9000 120 --name web1 --full 0
qm set 120 --sshkeys ~/.ssh/id_ed25519.pub
qm resize 120 scsi0 +20G && qm start 120

Options

Options of oic-sync proxmox sync. The full list is in oic-sync proxmox sync --help.

OptionMeaning
--node NAMENode to work on (default: the node named like this host).
--import-storageFile storage with the import content type, for downloads (default local).
--disk-storageStorage of the template disks, EFI vars and cloud-init drive (default local-lvm).
--bridgeBridge of net0 (default vmbr0).
--vmid-base NFirst VMID for templates, for example 9000 (default: the next free VMID of the cluster).
--memory MIBTemplate memory (default 2048 MiB).
--cores NTemplate CPU cores (default 2).
--image IDImage to handle, repeatable. Default: every image of the index except the service and test images.
--variant NAMEOnly this variant of multi-variant images (--variant uefi for Alpine).
--keep NVersions kept per image, the current one included (default 2).
--deleteDestroy versions beyond --keep, only when no linked clone uses them.
--dry-runRead the node and verify signatures, change nothing.
--no-verify-signatureSkip the cosign check (not recommended).
--index-url URLAnother index ($OIC_INDEX_URL), for example a mirror made with oic-sync mirror.
--timeoutSeconds to wait for an import step to finish (default 3600).

Skipped unless named with --image: the OpenStack service images octavia-amphora, manila-service-image and trove-guest-image, the test image cirros and the rescue image cloud-rescue.

What a template looks like

The same settings as the qm commands on each image page of this site:

  • virtio-scsi-single controller, scsi0 imported from the qcow2 with discard=on, virtio network on the bridge, serial console.
  • Cloud-init drive on ide2, ciuser set to the image login user, DHCP on net0.
  • QEMU guest agent enabled (except for images that do not ship it, such as CirrOS).
  • UEFI images: bios: ovmf, machine: q35 and an EFI disk without pre-enrolled keys.
  • Tags oic and oic-<image id>, and a machine-readable block in the description that oic-sync reads back.

Only VMs with these tags and this block are touched. Your own tags are kept. A clone copies the tags and the description, but its block names another VMID, so clones are never touched.

How it works

  1. Verify the cosign bundle against the sha256 of the index. A failed verification means no import.
  2. Create the VM shell with a free VMID.
  3. Download the qcow2 with Proxmox's own download-url, given the signed sha256: Proxmox checks the digest itself.
  4. Import the disk and add the cloud-init drive.
  5. Convert to a template, then delete the downloaded file.

On any failure, the VM and the downloaded file are removed. The current version is named after the image ID (debian-13), older versions <image id>-<version> with the tag oic-retired. The name moves to the newest template at each sync, so automation should look templates up by tag and name at clone time.

With --delete, a version beyond --keep is destroyed only when no VM of the cluster is a linked clone of it. An import that never became a template (crashed run) is removed after 6 hours, with its downloaded file.

Run it daily

The index is rebuilt once a day, so a daily run is enough. On the node, as root:

systemd service
# /etc/systemd/system/oic-sync-proxmox.service
[Service]
Type=oneshot
ExecStart=/root/.local/bin/oic-sync proxmox sync --image debian-13 --vmid-base 9000 --keep 2
systemd timer
# /etc/systemd/system/oic-sync-proxmox.timer
[Timer]
OnCalendar=daily
RandomizedDelaySec=1h
Persistent=true

[Install]
WantedBy=timers.target
bash
systemctl enable --now oic-sync-proxmox.timer

Run it from one timer only (see below).

Limitations

  • Alpha, and no release yet: install from GitHub as above.
  • One node per run, through the local API as root. Run it on each node that needs templates on local storage, or once for a shared storage. No remote mode, no API token.
  • VMs only (no LXC templates). qcow2 images only.
  • Tested on Proxmox VE 9.2 with LVM-thin (the default local-lvm) and directory storages: BIOS and UEFI templates, linked clones, rotation, interrupted runs. ZFS and Ceph disk storages should work but have not been tried yet: start with --dry-run and a single --image.
  • Two runs at the same time on one node may import the same version twice: run it from one timer only.

Full reference: the Proxmox VE section of the oic-sync README. Problems go to its issue tracker.