{"id":15602373,"url":"https://github.com/trfore/packer-proxmox-templates","last_synced_at":"2025-04-19T20:19:27.759Z","repository":{"id":257807640,"uuid":"841505408","full_name":"trfore/packer-proxmox-templates","owner":"trfore","description":"Turnkey Packer templates for downloading Debian, Fedora, and Ubuntu images on Proxmox (PVE) and creating PVE templates.","archived":false,"fork":false,"pushed_at":"2025-03-28T13:05:46.000Z","size":44,"stargazers_count":2,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-28T14:21:58.819Z","etag":null,"topics":["packer","packer-templates","proxmox","proxmox-template"],"latest_commit_sha":null,"homepage":"https://trfore.com/posts/golden-images-and-proxmox-templates-with-packer?utm_source=github","language":"HCL","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-08-12T14:39:04.000Z","updated_at":"2025-03-28T13:02:11.000Z","dependencies_parsed_at":"2024-10-03T02:41:21.752Z","dependency_job_id":"86de255c-06a5-44a5-9dae-8e43127c5013","html_url":"https://github.com/trfore/packer-proxmox-templates","commit_stats":null,"previous_names":["trfore/packer-proxmox-templates"],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trfore%2Fpacker-proxmox-templates","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trfore%2Fpacker-proxmox-templates/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trfore%2Fpacker-proxmox-templates/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trfore%2Fpacker-proxmox-templates/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trfore","download_url":"https://codeload.github.com/trfore/packer-proxmox-templates/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249791728,"owners_count":21326220,"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":["packer","packer-templates","proxmox","proxmox-template"],"created_at":"2024-10-03T02:41:18.615Z","updated_at":"2025-04-19T20:19:27.740Z","avatar_url":"https://github.com/trfore.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Packer Proxmox Templates\n\nTurnkey Packer templates for downloading Debian, Fedora, and Ubuntu images on Proxmox (PVE) and creating PVE templates -\nsee below for details on [CentOS](#centos).\n\n```sh\n# create a SSH key for Packer\nssh-keygen -o -a 100 -t ed25519 -f ~/.ssh/packer_id_ed25519 -C \"Packer\"\n\n# clone the repo \u0026 cd into it\ngit clone https://github.com/trfore/packer-proxmox-templates.git\ncd packer-proxmox-templates\n\n# initialize packer\npacker init common/.\n\n# choose a distro\ncd ubuntu\n\n# create the PVE templates\npacker build \\\n-var='pve_api_url=https://pve.example.com/api2/json' \\\n-var='pve_node=pve' \\\n-var='pve_username=packer@pve!token' \\\n-var='pve_token=782a7700-4010-4802-8f4d-820f1b226850' \\\n.\n```\n\n**NOTE**: The **default user** is the distributions name, e.g. `ubuntu`, with the exception of CentOS being\n`cloud-user`. Cloud-init will create a default user on all cloned VMs,\n**must add SSH key(s) and/or password in the Proxmox GUI cloud-init settings to access the VM** - SSH only\naccepts key based authentication. All images have `cloud-init`, `openssh-server` and `qemu-guest-agent` installed.\n\n**NOTE**: All images are built using only the `root` user, **no default users are created during the build**. We suggest\ncreating a temporary SSH key-pair for Packer to use, i.e. `packer_id_ed25519`. This key is removed from the `root`\naccount prior to finishing the build. After the build, `root` SSH access is disabled.\n\n```sh\nssh-keygen -o -a 100 -t ed25519 -f ~/.ssh/packer_id_ed25519 -C \"Packer\"\n```\n\n## Repo Layout\n\n- Common files are stored in `common/`, with each distribution folder containing symlinks to these files.\n\n  - [`iso-vars.pkr.hcl`](common/iso-vars.pkr.hcl) contains ISO URLs and boot commands for each distribution. This file\n    is updated as new releases become available.\n  - [`pve-image.pkr.hcl`](common/pve-image.pkr.hcl) is the main source file.\n  - [`pve-vars.pkr.hcl`](common/pve-vars.pkr.hcl) is used to store variables related to Proxmox.\n\n- cloud-init, kickstart, and preseed configurations are stored within the `configs/` folder and are\n  distribution-specific.\n\n- The `template/` folder is useful for generating new build configurations, as it:\n  - Contains symlinks to the common files.\n  - An [`template.auto.pkrvars.hcl`](template/template.auto.pkrvars.hcl) file for overwriting the default variable values.\n    - Note: If you clone or fork this repo, `.gitignore` is set to ignore other `.auto.pkrvars.hcl` files.\n  - An example build section in [`template.pkr.hcl`](template/template.pkr.hcl) with multiple approaches.\n\n## Grant Packer Access to Proxmox\n\n```sh Grant Packer Access to Proxmox\n# create role\npveum role add PackerUser --privs \"Datastore.AllocateSpace Datastore.AllocateTemplate Datastore.Audit Sys.Audit Sys.Modify VM.Allocate VM.Audit VM.Clone VM.Config.CDROM VM.Config.Cloudinit VM.Config.CPU VM.Config.Disk VM.Config.HWType VM.Config.Memory VM.Config.Network VM.Config.Options VM.Console VM.Monitor VM.PowerMgmt\"\n\n# create group\npveum group add packer-users\n\n# add permissions\npveum acl modify / -group packer-users -role PackerUser\n\n# create user 'packer'\npveum useradd packer@pve -groups packer-users\n\n# generate a token\npveum user token add packer@pve token -privsep 0\n```\n\nThe last command will output a token value similar to the following:\n\n```sh Example PVE Token\n┌──────────────┬──────────────────────────────────────┐\n│ key          │ value                                │\n╞══════════════╪══════════════════════════════════════╡\n│ full-tokenid │ packer@pve!token                     │\n├──────────────┼──────────────────────────────────────┤\n│ info         │ {\"privsep\":\"0\"}                      │\n├──────────────┼──────────────────────────────────────┤\n│ value        │ 782a7700-4010-4802-8f4d-820f1b226850 │\n└──────────────┴──────────────────────────────────────┘\n```\n\n## Packer Commands\n\nInitialize Packer:\n\n```sh\npacker init common/.\n```\n\nWith the symlinked common files, Packer commands work within each linux folder:\n\n```sh\ncd ubuntu\npacker fmt .\npacker init .\npacker validate .\n```\n\nDistro folders typically contain multiple images, you can limit the build by adding the `-except=` or `-only=` flag.\nExample passing Proxmox credentials:\n\n```sh\ncd ubuntu\n# build all images\npacker build \\\n-var='pve_api_url=https://pve.example.com/api2/json' \\\n-var='pve_node=node01' \\\n-var='pve_username=packer@pve!token' \\\n-var='pve_token=782a7700-4010-4802-8f4d-820f1b226850' \\\n.\n\n# build a single image\npacker build \\\n-var='pve_api_url=https://pve.example.com/api2/json' \\\n-var='pve_node=node01' \\\n-var='pve_username=packer@pve!token' \\\n-var='pve_token=782a7700-4010-4802-8f4d-820f1b226850' \\\n-only=proxmox-iso.ubuntu20 \\\n.\n```\n\n## Important Variables\n\nAll variables can be redefined using a `*.auto.pkrvars.hcl` file, see example file: [`template.auto.pkrvars.hcl`](template/template.auto.pkrvars.hcl).\nReminder: `.gitignore`is set to ignore other `.auto.pkrvars.hcl` files, so storing your personal values in a new file,\n`ubuntu.auto.pkrvars.hcl`, inside each distribution's directory will be ignored by git.\n\n| Variable                  | Default           | Description                                              | Required | Plugin Variable Equivalent |\n| ------------------------- | ----------------- | -------------------------------------------------------- | -------- | -------------------------- |\n| `pve_api_url`             |                   | String, Proxmox URL                                      | **Yes**  | `proxmox_url`              |\n| `pve_node`                | `pve`             | String, Proxmox target node for ISOs and templates       | **Yes**  | `node`                     |\n| `pve_username`            |                   | String, Proxmox username for Packer                      | **Yes**  | `username`                 |\n| `pve_token`               |                   | String, Proxmox token value for Packer                   | **Yes**  | `token`                    |\n| `iso_download_pve`        | `true`            | Boolean, All ISOs are downloaded to Proxmox              | No       |                            |\n| `cloud_init`              | `true`            | Boolean, Attach a cloud-init drive                       | No       | `cloud_init`               |\n| `cloud_init_storage_pool` | `local-lvm`       | String, Proxmox storage pool to use for cloud-init drive | No       | `cloud_init_storage_pool`  |\n| `scsi_controller`         | `virtio-scsi-pci` | String, SCSI controller model                            | No       |                            |\n| `disk_type`               | `scsi`            | String, Storage bus/device                               | No       | `type`                     |\n| `disk_storage_pool`       | `local-lvm`       | String, Storage pool name                                | No       | `storage_pool`             |\n| `disk_cache_mode`         | `writeback`       | String, Storage cache mode                               | No       | `cache_mode`               |\n| `disk_discard`            | `false`           | Boolean, Enable Discard/TRIM support                     | No       | `discard`                  |\n| `disk_ssd`                | `false`           | Boolean, Enable SSD emulation                            | No       | `ssd`                      |\n| `net_bridge`              | `vmbr0`           | String, NIC name                                         | No       | `bridge`                   |\n| `net_model`               | `virtio`          | String, NIC type                                         | No       | `model`                    |\n| `net_vlan_tag`            | `1`               | String, NIC VLAN tag                                     | No       | `vlan_tag`                 |\n\n### SSH\n\n**NOTE**: We suggest creating a temporary SSH key-pair for Packer to use during the build, i.e. `packer_id_ed25519`. This key is removed from the `root` account\nprior to finishing the build. Alternatively, you can use a pre-existing key and set: `ssh_keypair_name`, `ssh_private_key_file` and `ssh_public_key_file`.\nExample key generation:\n\n```sh\nssh-keygen -o -a 100 -t ed25519 -f ~/.ssh/packer_id_ed25519 -C \"Packer\"\n```\n\n| Variable                    | Default                        | Description                                                          | Required |\n| --------------------------- | ------------------------------ | -------------------------------------------------------------------- | -------- |\n| `ssh_username`              | `root`                         | String, SSH user for Packer build, used by SSH communicator          | No       |\n| `ssh_password`              | `password`                     | String, SSH user password for Packer build (**Debian** only)         | No       |\n| `ssh_timeout`               | `20m`                          | String, Packer SSH timeout                                           | No       |\n| `ssh_clear_authorized_keys` | `true`                         | Boolean, Remove the Packer SSH key from `/root/.ssh/authorized_keys` | No       |\n| `ssh_keypair_name`          | `packer_id_ed25519`            | String, SSH key name for Packer to use                               | **Yes**  |\n| `ssh_private_key_file`      | `~/.ssh/packer_id_ed25519`     | String, Private SSH key for Packer                                   | **Yes**  |\n| `ssh_public_key_file`       | `~/.ssh/packer_id_ed25519.pub` | String, Public SSH key for Packer                                    | **Yes**  |\n\n### VM IDs\n\nVM IDs, `vm_id`, default to `0` and will use the next free value from Proxmox. If you would like to fix these values\ncreate a `*.auto.pkrvars.hcl` within each OS folder (HCL type: `map(numeric)`):\n\n```HCL\n// ubuntu.auto.pkrvars.hcl\nvm_id = {\n  \"ubuntu20\" = 9020\n  \"ubuntu22\" = 9022\n  \"ubuntu24\" = 9024\n}\n```\n\n### Other Variables\n\nSee [`iso-vars.pkr.hcl`](common/iso-vars.pkr.hcl) and [`pve-vars.pkr.hcl`](common/pve-vars.pkr.hcl)\n\n## Distro Configurations\n\n### CentOS\n\n- The **default** user is `cloud-user`, update the **username**, **ssh key(s)**, and/or **password** using the Proxmox\n  cloud-init GUI.\n- [CentOS kickstart file (link)](centos/configs/anaconda-ks.cfg)\n- **Important**: CentOS URLs and checksums are intentionally not provided, as bandwidth is limited and ISOs are not\n  available from `mirror.centos.org`. To set a mirror create an auto vars file, `centos/centos.auto.pkrvars.hcl`, and\n  add the closest geographic mirror from the list: [CentOS 9 Stream Mirrors] or [Fedora Mirror Manager]. Alternatively,\n  create your own installation tree: [CentOS Docs - Creating Installation Sources for Kickstart].\n\n  | Variable                  | Default | Description                                                                | Required |\n  | ------------------------- | ------- | -------------------------------------------------------------------------- | -------- |\n  | `iso_url`                 | `''`    | Map(string), URL                                                           | **Yes**  |\n  | `iso_checksum`            | `''`    | Map(string), prepend URL with `file:`                                      | **Yes**  |\n  | `centos_install_url`      | `''`    | Map(string), URL - single source, not a mirror list                        | **Yes**  |\n  | `centos_mirror_appstream` | `''`    | Map(string), URL - mirror list, if set packages will be updated on install | No       |\n  | `centos_mirror_baseos`    | `''`    | Map(string), URL - mirror list, if set packages will be updated on install | No       |\n  | `centos_mirror_extras`    | `''`    | Map(string), URL - mirror list, if set packages will be updated on install | No       |\n\n  ```HCL\n  // centos.auto.pkrvars.hcl\n  centos_install_url = {\n    \"centos8\" = \"https://mirror.example.com/centos/8-stream/BaseOS/x86_64/os/\"\n    \"centos9\" = \"https://mirror.example.com/centos-stream/9-stream/BaseOS/x86_64/os/\"\n  }\n  iso_url = {\n    \"centos8\" = \"https://mirror.example.com/centos/8-stream/isos/x86_64/CentOS-Stream-8-x86_64-latest-boot.iso\"\n    \"centos9\" = \"https://mirror.example.com/centos-stream/9-stream/BaseOS/x86_64/iso/CentOS-Stream-9-latest-x86_64-boot.iso\"\n  }\n  iso_checksum = {\n    \"centos8\" = \"file:https://mirror.example.com/centos/8-stream/isos/x86_64/CHECKSUM\"\n    \"centos9\" = \"file:https://mirror.example.com/centos-stream/9-stream/BaseOS/x86_64/iso/CentOS-Stream-9-latest-x86_64-boot.iso.MD5SUM\"\n  }\n  ```\n\n### Fedora\n\n- The **default** user is `fedora`, update the **username**, **ssh key(s)**, and/or **password** using the Proxmox\n  cloud-init GUI.\n- [Fedora kickstart file (link)](fedora/configs/anaconda-ks.cfg)\n- **Note**: Kickstart files are **stored on the image** at `/root/*-ks.cfg`\n- Installed packages are based on the group `server-product-environment`, consisting of:\n\n  - Groups: `core`, `server-product`, `standard`\n  - Packages: `qemu-guest-agent`\n  - Excluding:\n    - `container-management`: buildah, CNI and podman\n    - `hardware-support`: Intel wireless cards (in `core`), Thunderbolt, Marvell and Netronome NICs\n    - `headless-management`: cockpit pkgs and openssh-server\n\n  ```sh\n  $ dnf group info server-product-environment\n  Environment Group: Server\n  Description: An integrated, easy-to-manage server.\n  Mandatory Groups:\n    Container Management\n    Core\n    Hardware Support\n    Headless Management\n    Server product core\n    Standard\n  ...\n  ```\n\n### Debian\n\n- The **default** user is `debian`, update the **username**, **ssh key(s)**, and/or **password** using the Proxmox\n  cloud-init GUI.\n- [Debian preseed file (link)](debian/configs/preseed.cfg)\n\n### Ubuntu\n\n- The **default** user is `ubuntu`, update the **username**, **ssh key(s)**, and/or **password** using the Proxmox\n  cloud-init GUI.\n- [Ubuntu cloud-config file (link)](ubuntu/configs/user-data)\n- Setting `apt_proxy_http` and/or `apt_proxy_https`, creates a proxy file at `/etc/apt/apt.conf.d/90curtin-aptproxy`.\n  Set using format: `\"https://[[user][:pass]@]host[:port]/\"`, also possible to set value of `\"DIRECT\"` when using\n  [Apt-Cacher NG](https://help.ubuntu.com/community/Apt-Cacher%20NG).\n\n  | Variable          | Default | Description                                                         | Required |\n  | ----------------- | ------- | ------------------------------------------------------------------- | -------- |\n  | `apt_proxy_http`  | `''`    | String, APT proxy URL for Ubuntu. Default value skips setting proxy | No       |\n  | `apt_proxy_https` | `''`    | String, APT proxy URL for Ubuntu. Default value skips setting proxy | No       |\n\n- Result of setting `apt_proxy_http=\"http://192.168.100.2:3142\"` and `apt_proxy_https=\"DIRECT\"`:\n\n  ```sh\n  # /etc/apt/apt.conf.d/90curtin-aptproxy\n  Acquire::http::proxy \"http://192.168.100.2:3142\";\n  Acquire::https::proxy \"DIRECT\";\n  ```\n\n## Maintainers \u0026 License\n\nTaylor Fore [(@trfore)](https://github.com/trfore)\n\nSee [LICENSE](LICENSE) File\n\n## References\n\nBlog Post:\n\n- [Golden Images and Proxmox Templates with Packer](https://trfore.com/posts/)\n\nPacker:\n\n- [Packer](https://developer.hashicorp.com/packer)\n- [Packer Docs: Build Command](https://developer.hashicorp.com/packer/docs/commands/build)\n- [Packer Plugin: Proxmox](https://developer.hashicorp.com/packer/integrations/hashicorp/proxmox)\n- [GitHub: hashicorp/packer-plugin-proxmox](https://github.com/hashicorp/packer-plugin-proxmox)\n\nCentOS:\n\n- [CentOS Docs - Creating Installation Sources for Kickstart]\n- [CentOS 8 Stream Mirrors](http://isoredirect.centos.org/centos/8-stream/isos/x86_64/)\n- [CentOS 9 Stream Mirrors]\n- [Fedora Mirror Manager]\n\nDebian:\n\n- [Debian Release - Stable](https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/)\n- [Debian Release - Archive](https://get.debian.org/images/archive/)\n- [Debian Preseed](https://wiki.debian.org/DebianInstaller/Preseed)\n- [Debian Installation Guide - Preseeding](https://www.debian.org/releases/stable/amd64/apb.en.html)\n- [Debian Preseed Example](https://www.debian.org/releases/stable/example-preseed.txt)\n\nFedora:\n\n- [Fedora Server](https://fedoraproject.org/en/server/download)\n- [Fedora Mirror Manager]\n- [Fedora Docs: Automating the Installation with Kickstart](https://docs.fedoraproject.org/en-US/fedora/f36/install-guide/advanced/Kickstart_Installations/)\n- [Fedora Docs: Kickstart Syntax Reference](https://docs.fedoraproject.org/en-US/fedora/f36/install-guide/appendixes/Kickstart_Syntax_Reference/#appe-kickstart-syntax-reference)\n\nUbuntu:\n\n- [Ubuntu Releases](https://releases.ubuntu.com/)\n- [Ubuntu Docs: Automated Server Installation](https://ubuntu.com/server/docs/install/autoinstall)\n\n[CentOS Docs - Creating Installation Sources for Kickstart]: https://docs.centos.org/en-US/8-docs/advanced-install/assembly_creating-installation-sources-for-kickstart-installations/\n[CentOS 9 Stream Mirrors]: https://www.centos.org/download/mirrors/\n[Fedora Mirror Manager]: https://mirrors.fedoraproject.org/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrfore%2Fpacker-proxmox-templates","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrfore%2Fpacker-proxmox-templates","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrfore%2Fpacker-proxmox-templates/lists"}