Skip to content

Guide

Keep OpenStack Glance images up to date with oic-sync

Import the signed qcow2 images of this catalog into Glance, under stable names, and keep them current with one command run once a day. When everything is up to date, it changes nothing.

What it does

oic-sync reads the catalog index, verifies the cosign signature of each image, and imports the versions your cloud does not have yet. The newest version gets a stable name ("Debian 13"); older versions are renamed and hidden, then rotated out.

  • No local state: the images in Glance carry everything it needs to know.
  • Idempotent: run it twice, the second run changes nothing. A daily run from a systemd timer, a Kubernetes CronJob or a CI job is enough.
  • Works for a project (private images) or for an operator (public images).

Status: alpha. License: Apache-2.0. The same tool also keeps Proxmox VE templates up to date.

Install

oic-sync is on PyPI. The OpenStack backend needs openstacksdk, pulled in by the openstack extra. Python 3.10 or newer.

pipx
pipx install 'oic-sync[openstack]'
# or the signed container image (OpenStack backend included)
docker run --rm -v ~/.config/openstack:/etc/openstack:ro \
  ghcr.io/open-img-cloud/oic-sync openstack status --cloud mycloud

Credentials come from the standard clouds.yaml (--cloud), or from OS_* environment variables when no cloud is named. An application credential restricted to the image service is enough, plus read access to servers and volumes for --delete.

First run

Start read only: status compares the cloud with the index, --dry-run shows what a sync would do. Then run the sync for real.

bash
# What the index offers (no cloud needed)
oic-sync list
# Verify the cosign signatures of the index (no cloud needed)
oic-sync verify --image debian-13

# Compare a cloud with the index (read only)
oic-sync openstack status --cloud mycloud
# Show what a sync would do (read only, signatures verified)
oic-sync openstack sync --cloud mycloud --image debian-13 --image ubuntu-24.04 --dry-run
# Do it
oic-sync openstack sync --cloud mycloud --image debian-13 --image ubuntu-24.04 --keep 2

Cloud operators publish public images and delete old versions that nothing uses:

operator
oic-sync openstack sync --cloud admin --visibility public --keep 3 --delete

openstack status --check exits with 1 when an image is not up to date, for monitoring. Exit codes: 0 success, 1 at least one image failed, 2 invalid arguments or index.

Options

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

OptionMeaning
--image IDImage to handle, repeatable. Default: every image of the index except the service and test images (see below).
--include-service-imagesAlso handle the service images when no --image is given.
--variant NAMEOnly this variant of multi-variant images (--variant uefi for Alpine).
--keep NVersions kept per image, the current one included (default 2).
--deleteDelete versions beyond --keep, only when no instance and no volume uses them.
--visibilityprivate (default), shared, community or public (operators).
--dry-runRead the cloud and verify signatures, change nothing.
--import-methodauto (default), web-download, glance-direct or upload.
--property K=VExtra or overriding Glance property (the oic_* keys are reserved).
--with-optional-propertiesAdd hw_rng_model=virtio (flavors must allow hw_rng:allowed).
--no-verify-signatureSkip the cosign check (not recommended).
--index-url URLAnother index ($OIC_INDEX_URL), for example a mirror made with oic-sync mirror.
--cloud, --regionclouds.yaml entry and region ($OS_CLOUD).
--timeoutSeconds to wait for an import to finish (default 3600).

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

How it works

For each selected image (in one variant):

  1. Find. Our images are found in Glance by their properties (oic_id, plus oic_variant for multi-variant images), owned by the current project. Nothing else is touched.
  2. Verify. The cosign bundle is checked against the sha256 of the index: the image must have been signed by an open-img-cloud build workflow on GitHub Actions. A failed verification means no import.
  3. Import. The image is created hidden under a versioned name, with the Glance properties of the index (os_distro, hw_disk_bus, hw_firmware_type...) and min_disk from the virtual size. With the Glance web-download import method, Glance downloads it and its sha512 must match the index. Otherwise the image is streamed from the CDN to Glance, with sha256, sha512 and size checked on the fly; nothing is written to disk. On any mismatch, the new image is deleted.
  4. Promote. The verified image takes the stable name ("Debian 13") and is unhidden.
  5. Retire. Older versions are renamed "Debian 13 (13-20261026-2643)" and hidden. They leave image lists but stay usable by ID, so existing servers, rebuilds and Terraform states keep working.
  6. Rotate. The --keep newest versions are kept. With --delete, older ones are deleted when no server and no volume uses them.

Failed or abandoned imports of a previous run are removed. The signature covers the sha256; with web-download, Glance only checks the sha512, which comes from the build manifest over HTTPS but is not itself signed. Use --import-method upload to check the signed digest on every byte. More on signatures in the verification guide.

Terraform and OpenTofu

The stable name moves to each new version. A data source that looks an image up by name will pick the new image after a sync, which can plan the replacement of existing servers. Look images up by property instead, and ignore image changes on long-lived servers:

hcl
data "openstack_images_image_v2" "debian" {
  properties  = { oic_id = "debian-13" }
  most_recent = true
}

Run it daily

The index is rebuilt once a day, so a daily run is enough. A systemd service and timer, from the repository examples. Put clouds.yaml in /etc/openstack/clouds.yaml, readable by the service, and set ExecStart to where oic-sync is installed.

systemd service
# /etc/systemd/system/oic-sync.service
[Unit]
Description=Sync openimages.cloud images into OpenStack Glance
Documentation=https://github.com/open-img-cloud/oic-sync
Wants=network-online.target
After=network-online.target

[Service]
Type=oneshot
DynamicUser=yes
# Sigstore trust root cache (~/.cache/sigstore).
CacheDirectory=oic-sync
Environment=HOME=/var/cache/oic-sync
Environment=OS_CLOUD=mycloud
ExecStart=/usr/local/bin/oic-sync openstack sync --image debian-13 --image ubuntu-24.04 --keep 2
# Hardening: oic-sync only needs outbound HTTPS.
NoNewPrivileges=yes
ProtectSystem=strict
ProtectHome=yes
PrivateTmp=yes
PrivateDevices=yes
ProtectKernelTunables=yes
ProtectKernelModules=yes
ProtectControlGroups=yes
RestrictAddressFamilies=AF_INET AF_INET6
RestrictNamespaces=yes
LockPersonality=yes
SystemCallArchitectures=native
systemd timer
# /etc/systemd/system/oic-sync.timer
[Unit]
Description=Daily sync of openimages.cloud images

[Timer]
# The catalog index is rebuilt once a day; any time after 08:00 UTC is fine.
OnCalendar=*-*-* 09:00:00 UTC
RandomizedDelaySec=1h
Persistent=yes

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

For Kubernetes, see the CronJob example.

Limitations

  • Alpha: start with --dry-run.
  • Only images of the current project are handled. With --delete, a version is kept when its use cannot be determined (no admin view of other projects for a public image).
  • The stable name moves at each sync: automation should look images up by property.

Full reference, including every option and edge case: the oic-sync README on GitHub. Problems go to its issue tracker.