{"id":18537253,"url":"https://github.com/trfore/proxmox-template-scripts","last_synced_at":"2025-11-01T03:30:23.437Z","repository":{"id":261278170,"uuid":"834290403","full_name":"trfore/proxmox-template-scripts","owner":"trfore","description":"Collection of Bash Scripts to Download Images and Create PVE Templates","archived":false,"fork":false,"pushed_at":"2024-11-05T16:46:51.000Z","size":29,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-26T03:42:01.834Z","etag":null,"topics":["proxmox","proxmox-template","proxmox-tools"],"latest_commit_sha":null,"homepage":"https://www.trfore.com/posts/golden-images-and-proxmox-templates-using-cloud-init?utm_source=github","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/trfore.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-26T21:26:21.000Z","updated_at":"2024-12-03T21:51:37.000Z","dependencies_parsed_at":"2024-11-05T17:46:51.144Z","dependency_job_id":null,"html_url":"https://github.com/trfore/proxmox-template-scripts","commit_stats":null,"previous_names":["trfore/proxmox-template-scripts"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trfore%2Fproxmox-template-scripts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trfore%2Fproxmox-template-scripts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trfore%2Fproxmox-template-scripts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trfore%2Fproxmox-template-scripts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trfore","download_url":"https://codeload.github.com/trfore/proxmox-template-scripts/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239255294,"owners_count":19608253,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["proxmox","proxmox-template","proxmox-tools"],"created_at":"2024-11-06T19:37:37.131Z","updated_at":"2025-11-01T03:30:23.408Z","avatar_url":"https://github.com/trfore.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Creating Proxmox Templates with cloud-init\n\nCollection of example cloud-init config files and shell scripts to download cloud-images and create\n[Proxmox templates].\n\nBlog post: [Golden Images and Proxmox Templates with cloud-init]\n\n## Cloud-init Files\n\n- [`vendor-data-minimal.yaml`](/cloud-init/vendor-data-minimal.yaml): A minimal\n  cloud-init file for running a VM on Proxmox.\n\n## Shell Scripts\n\n- [`build-template`](/scripts/build-template): Create a proxmox template.\n- [`image-update`](/scripts/image-update): Check for an updated image and\n  download the latest or missing image.\n  - Works with `centos`, `debian` and `ubuntu` cloud images.\n  - Limited support for `fedora`, as the image value is hardcoded to the latest\n    version.\n  - **Requires** `curl`\n  - **Note**: This script will change the file extension to `*.img` for visibility in the Proxmox GUI, `qm disk import`\n    will automatically convert disk image.\n\n## Systemd Templates\n\n- [image-update@.service](/systemd-timer/image-update@.service) and\n  [image-update@.timer](/systemd-timer/image-update@.timer)\n  - Details below: [Automatically update images using systemd timers](#automatically-check-for-updates-using-systemd-timers)\n  - **Note**: Change the day and time this script runs on, `OnCalendar=*-*-10 02:00:00`.\n\n## Use\n\n- Copy the [scripts](/scripts/) into `/usr/local/bin` on your Proxmox node(s).\n- Change the scripts ownership and permissions:\n\n  ```bash\n  chown root:root /usr/local/bin/{build-template,image-update}\n  chmod +x /usr/local/bin/{build-template,image-update}\n  ```\n\n- Confirm `/usr/local/bin` is added to `PATH`:\n\n  ```bash\n  root@pve:~$ echo $PATH\n  /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\n\n  # test using tab-completion\n  image[TAB] -\u003e image-update\n  ```\n\n### Image Download / Update Script\n\n```bash\n# SSH into your Proxmox host\nuser@desktop:~$ ssh root@pve\n\n# usage\nroot@pve:~$ image-update -d \u003cDISTRO_NAME\u003e -r \u003cRELEASE_NAME\u003e [ARGS]\n```\n\n\u003cdetails\u003e\n  \u003csummary\u003eCode Examples\u003c/summary\u003e\n\n```bash\nimage-update -d centos -r 9\n```\n\n```bash\nimage-update -d debian -r 12\n```\n\n```bash\nimage-update -d fedora -r 40\n```\n\n```bash\nimage-update -d ubuntu -r 22\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eAlternative Usage\u003c/summary\u003e\n\n```bash\n# usage\nimage-update \u003cDISTRO_NAME\u003e-\u003cRELEASE_NAME\u003e [ARGS]\n# example\nimage-update ubuntu-20 --remove\n```\n\n\u003c/details\u003e\n\n| CLI Flags         | Description                                                               | Default                    | Required |\n| ----------------- | ------------------------------------------------------------------------- | -------------------------- | -------- |\n| `--distro`, `-d`  | Specify the distribution name, e.g. `ubuntu`.                             |                            | **Yes**  |\n| `--release`, `-r` | Specify the release name, e.g. `focal` or `20`.                           |                            | **Yes**  |\n| `--backup`, `-b`  | Backup the existing image before updating. Not compatible with `--remove` | `false`                    | No       |\n| `--date`          | Append the date to the image name, e.g. `ubuntu*-$DATE.img`               | `false`                    | No       |\n| `--remove`        | Remove image and backups before updating. Not compatible with `--backup`  | `false`                    | No       |\n| `--storage`, `-s` | Specify the image storage path                                            | `/var/lib/vz/template/iso` | No       |\n\nAdding the `--backup` flag will backup existing images for the set **distribution and release** before downloading the\nlatest image, using the naming scheme: `IMAGE_NAME.backup.img`.\n\nAdding the `--date` flag will append the release date to name in `YYYY-MM-DD` or `YYYY-MMM-DD` format, e.g.\n`ubuntu-20.04-server-cloudimg-amd64-YYYY-MM-DD.img`. The format is not configurable as it is pulled from the\ndistribution's release page.\n\n#### Automatically Check for Updates Using Cron\n\nThe majority of images are updated every 1 to 2 months, so be considerate and don't check more than once a month for\nnew cloud images. **Note**: Consider staggering cron jobs to different minute (`0`), hour (`2`), and day (`10`) across\ndistributions and releases.\n\n```bash\n0 2 10 * * /usr/local/bin/image-update -d \u003cdistro_name\u003e -r \u003crelease_name\u003e\n```\n\nExample:\n\n```bash\n# create/edit crontab\ncrontab -e\n\n# create a job\n10 3 15 * * /usr/local/bin/image-update -d ubuntu -r focal\n```\n\n#### Automatically Check for Updates Using Systemd Timers\n\nThe `image-update` script can also parse a single argument for distribution and release, `image-update ubuntu-20`, which\nis useful in creating systemd timers. You can still pass the `--remove` and `--storage` flags as well, however,\n`--distro` and `--release` are overridden when using this approach.\n\nTo use systemd timers, add the [template files](/systemd-timer/) to the `/etc/systemd/system` directory and start at\nstep 3. Or create a service and timer template, as follows:\n\n1. Create a service, `image-update@.service`, in the `/etc/systemd/system` directory. Add additional script flags to\n   `ExecStart=` after `%i`.\n\n   ```xml\n   [Unit]\n   After=network-online.target\n   Description= Check for updated cloud image %i\n   Documentation=https://github.com/trfore/proxmox-template-scripts\n\n   [Service]\n   Type=oneshot\n   ExecStart=/usr/local/bin/image-update %i --remove\n   ```\n\n2. Create a timer, `image-update@.timer`, in the `/etc/systemd/system` directory. **Note**: Change the day and time this\n   script runs on, `OnCalendar=*-*-10 02:00:00`. To prevent multiple timers from triggering simultaneously,\n   `RandomizedDelaySec=3h` will randomly select a time within a 3-hour window and `AccuracySec=1us` will prevent systemd\n   from grouping the timers.\n\n   ```xml\n   [Unit]\n   Description=Check for updated cloud image %i\n   Documentation=https://github.com/trfore/proxmox-template-scripts\n\n   [Timer]\n   OnCalendar=*-*-10 02:00:00\n   AccuracySec=1us\n   RandomizedDelaySec=3h\n   Persistent=true\n\n   [Install]\n   WantedBy=timers.target\n   ```\n\n3. Reload the systemd configuration\n\n   ```bash\n   systemctl daemon-reload\n   ```\n\n4. Create a Timer, using the format `image-update@\u003cDISTRO\u003e-\u003cRELEASE\u003e.timer`\n\n   ```bash\n   # enable and start a timer\n   systemctl enable image-update@ubuntu-20.timer --now\n   ```\n\nAdditional commands:\n\n```bash\n# view all timers\nsystemctl list-timers --all\n\n# view timer status\nsystemctl status image-update@ubuntu-20.timer\n\n# disable a timer\nsystemctl disable image-update@ubuntu-20.timer\n\n# view script update logs\nsystemctl status image-update@ubuntu-20.service\n```\n\n### Proxmox Template Script\n\n[`build-template`](/scripts/build-template): A wrapper script around `qm` to build Proxmox templates. This script\nassumes the use of cloud-init vendor data file located at `local:snippets/vendor-data.yaml`. Detailed usage available on\nthe blog post: [Golden Images and Proxmox Templates with cloud-init], and example file:\n[`cloud-init/vendor-data-minimal.yaml`](/cloud-init/vendor-data-minimal.yaml).\n\n```bash\n# usage\nbuild-template -i \u003cvm_id\u003e -n \u003cvm_name\u003e --img \u003cvm_image\u003e [ARGS]\n```\n\nExample:\n\n```bash\nbuild-template -i 9000 -n ubuntu20 --img /var/lib/vz/template/iso/ubuntu-20.04-server-cloudimg-amd64.img\n```\n\n| CLI Flags          | Description                                                       | Default            | Required |\n| ------------------ | ----------------------------------------------------------------- | ------------------ | -------- |\n| `--id`, `-i`       | Specify the VM ID (1-999999999)                                   | `9000`             | **Yes**  |\n| `--name`, `-n`     | Specify the VM name                                               | `template`         | **Yes**  |\n| `--image`, `--img` | Specify the VM image (path), ex: `/PATH/TO/image.{img,iso,qcow2}` |                    | **Yes**  |\n| `--bios`, `-b`     | Specify the VM bios, `seabios` or `ovmf`                          | `seabios`          | No       |\n| `--machine`        | Specify the VM machine type, `q35` or `pc` for i440               | `q35`              | No       |\n| `--memory`, `-m`   | Specify the VM memory                                             | `1024`             | No       |\n| `--net-bridge`     | Specify the VM network bridge                                     | `vmbr0`            | No       |\n| `--net-type`       | Specify the VM network type                                       | `virtio`           | No       |\n| `--net-vlan`       | Specify the VM network vlan tag                                   | `1`                | No       |\n| `--os`             | Specify the VM OS                                                 | `l26`              | No       |\n| `--resize`         | Increase the VM boot disk size                                    | `1G`               | No       |\n| `--storage`, `-s`  | Specify the VM storage                                            | `local-lvm`        | No       |\n| `--scsihw`         | Specify the VM storage controller                                 | `virtio-scsi-pci`  | No       |\n| `--vendor-file`    | Specify the cloud-init vendor file                                | `vendor-data.yaml` | No       |\n\n## Maintainers \u0026 License\n\nTaylor Fore (\u003chttps://github.com/trfore\u003e)\n\nSee [LICENSE](LICENSE) File\n\n## References\n\nBlog Post:\n\n- [Golden Images and Proxmox Templates with cloud-init]\n\nLinux Cloud Images:\n\n- [OpenStack: Cloud Images], collection of image links.\n- [CentOS Cloud Images]\n  - Default User: `centos`\n  - Uses: `CentOS-Stream-GenericCloud-X-latest.x86_64.qcow2`\n- [Debian Cloud Images]\n  - Default User: `debian`\n  - Uses `debian-1x-generic-amd64.qcow2`\n- [Fedora Cloud Images]\n  - Default User: `fedora`\n  - Uses `Fedora-Cloud-Base-Generic.x86_64-XX-XX.qcow2`\n- [Ubuntu Cloud Images]\n  - Default User: `ubuntu`\n  - Uses `ubuntu-2x.04-server-cloudimg-amd64.img`\n\nProxmox:\n\n- [Proxmox]\n- [Proxmox templates]\n\n[CentOS Cloud Images]: https://cloud.centos.org/\n[Debian Cloud Images]: https://cloud.debian.org/images/cloud/\n[Fedora Cloud Images]: https://fedoraproject.org/cloud/download\n[Ubuntu Cloud Images]: https://cloud-images.ubuntu.com/releases/\n[OpenStack: Cloud Images]: https://docs.openstack.org/image-guide/obtain-images.html\n[Golden Images and Proxmox Templates with cloud-init]: https://www.trfore.com/posts/golden-images-and-proxmox-templates-using-cloud-init/\n[Proxmox]: https://www.proxmox.com/\n[Proxmox templates]: https://pve.proxmox.com/wiki/VM_Templates_and_Clones\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrfore%2Fproxmox-template-scripts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrfore%2Fproxmox-template-scripts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrfore%2Fproxmox-template-scripts/lists"}