{"id":26249820,"url":"https://github.com/trfore/terraform-bpg-proxmox","last_synced_at":"2025-04-24T02:07:39.290Z","repository":{"id":280872184,"uuid":"829109559","full_name":"trfore/terraform-bpg-proxmox","owner":"trfore","description":"Terraform Modules for the BPG Proxmox Provider","archived":false,"fork":false,"pushed_at":"2025-04-10T19:27:57.000Z","size":57,"stargazers_count":7,"open_issues_count":1,"forks_count":5,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-24T02:07:30.797Z","etag":null,"topics":["proxmox","terraform","terraform-module"],"latest_commit_sha":null,"homepage":"https://trfore.com/posts/provisioning-proxmox-8-vms-with-terraform-and-bpg?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":"CONTRIBUTING.md","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,"zenodo":null}},"created_at":"2024-07-15T19:23:12.000Z","updated_at":"2025-04-10T18:55:40.000Z","dependencies_parsed_at":"2025-03-05T19:32:24.181Z","dependency_job_id":"8ae018f7-3dc8-4a25-a07c-487f0d5f4260","html_url":"https://github.com/trfore/terraform-bpg-proxmox","commit_stats":null,"previous_names":["trfore/terraform-bpg-proxmox"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trfore%2Fterraform-bpg-proxmox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trfore%2Fterraform-bpg-proxmox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trfore%2Fterraform-bpg-proxmox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trfore%2Fterraform-bpg-proxmox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trfore","download_url":"https://codeload.github.com/trfore/terraform-bpg-proxmox/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250546080,"owners_count":21448260,"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","terraform","terraform-module"],"created_at":"2025-03-13T15:49:59.314Z","updated_at":"2025-04-24T02:07:39.277Z","avatar_url":"https://github.com/trfore.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Terraform BPG Proxmox Modules\n\nThis repository contains modules and examples for deploying linux containers and virtual machines on [Proxmox] using\n[Terraform] or [OpenTofu] with the [BPG Proxmox] provider.\n\n## Requirements\n\n| Name          | Version   |\n| ------------- | --------- |\n| [Terraform]   | \u003e= 1.5.0  |\n| [OpenTofu]    | \u003e= 1.6.0  |\n| [Proxmox]     | \u003e= 8.0    |\n| [BPG Proxmox] | \u003e= 0.53.1 |\n\n## Image Module\n\n\u003cdetails\u003e\n  \u003csummary\u003eCode Example: Download VM Images\u003c/summary\u003e\n\n```HCL\nmodule \"ubuntu22\" {\n  source = \"github.com/trfore/terraform-bpg-proxmox//modules/image\"\n\n  node           = \"pve\"\n  image_url      = \"https://cloud-images.ubuntu.com/releases/22.04/release-20240207/ubuntu-22.04-server-cloudimg-amd64.img\"\n  image_checksum = \"7eb9f1480956af75359130cd41ba24419d6fd88d3af990ea9abe97c2f9459fda\"\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eCode Example: Download Linux Containers\u003c/summary\u003e\n\n```HCL\n# LXC are updated daily, set DATE and SHASUM values!\nmodule \"lxc_ubuntu22\" {\n  source = \"github.com/trfore/terraform-bpg-proxmox//modules/image\"\n\n  node               = \"pve\"\n  image_filename     = \"ubuntu-22.04-cloudimg-amd64-\u003cDATE\u003e.tar.xz\"\n  image_url          = \"https://images.linuxcontainers.org/images/ubuntu/jammy/amd64/cloud/\u003cDATE\u003e_07%3A42/rootfs.tar.xz\"\n  image_checksum     = \"\u003cSHASUM\u003e\"\n  image_content_type = \"vztmpl\"\n}\n```\n\n\u003c/details\u003e\n\n- The module can also be used to download multiple images and/or containers. See [`examples/image`](./examples/image/main.tf)\n  for full working examples.\n- See [`modules/image/README.md`](./modules/image/README.md#inputs) for a list of variables.\n\n## LXC Container Module\n\n\u003cdetails\u003e\n  \u003csummary\u003eCode Example: Create A Linux Container\u003c/summary\u003e\n\n```HCL\nmodule \"single_lxc\" {\n  source = \"github.com/trfore/terraform-bpg-proxmox//modules/lxc\"\n\n  node                = \"pve\"\n  lxc_id              = 100\n  lxc_name            = \"lxc-example\"\n  description         = \"terraform provisioned on ${timestamp()}\"\n  tags                = [\"ubuntu\"]\n  os_template         = \"local:vztmpl/ubuntu-22.04-standard_22.04-1_amd64.tar.zst\"\n  os_type             = \"ubuntu\"\n  vcpu                = 1\n  memory              = 1024\n  memory_swap         = 1024\n  user_ssh_key_public = \"~/.ssh/id_ed25519.pub\"\n  vlan_tag            = 1\n  ipv4 = [\n    {\n      ipv4_address = \"192.168.1.100/24\"\n      ipv4_gateway = \"192.168.1.1\"\n    },\n  ]\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eCode Example: Create Multiple Linux Containers\u003c/summary\u003e\n\n```HCL\nmodule \"multiple_lxc\" {\n  source = \"github.com/trfore/terraform-bpg-proxmox//modules/lxc\"\n\n  for_each = tomap({\n    \"lxc-example-01\" = {\n      id       = 101\n      template = \"local:vztmpl/ubuntu-20.04-standard_20.04-1_amd64.tar.gz\"\n      os_type  = \"ubuntu\"\n    },\n    \"lxc-example-02\" = {\n      id       = 102\n      template = \"local:vztmpl/ubuntu-22.04-standard_22.04-1_amd64.tar.zst\"\n      os_type  = \"ubuntu\"\n    },\n  })\n\n  node                = \"pve\"\n  lxc_id              = each.value.id\n  lxc_name            = each.key\n  os_template         = each.value.template\n  os_type             = each.value.os_type\n  user_ssh_key_public = \"~/.ssh/id_ed25519.pub\"\n}\n```\n\n\u003c/details\u003e\n\n- See [`examples/lxc`](./examples/lxc/main.tf) for full working examples.\n- See [`modules/lxc/README.md`](./modules/lxc/README.md#inputs) for a list of variables.\n\n## VM Clone Module\n\n\u003cdetails\u003e\n  \u003csummary\u003eCode Example: Clone A Single VM\u003c/summary\u003e\n\n```HCL\nmodule \"single_vm\" {\n  source = \"github.com/trfore/terraform-bpg-proxmox//modules/vm-clone\"\n\n  node        = \"pve\"\n  vm_id       = 100\n  vm_name     = \"vm-example\"\n  template_id = 9000\n  ci_ssh_key  = \"~/.ssh/id_ed25519.pub\"\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eCode Example: Clone Multiple VMs\u003c/summary\u003e\n\n```HCL\nmodule \"multiple_vm\" {\n  source = \"github.com/trfore/terraform-bpg-proxmox//modules/vm-clone\"\n\n  for_each = tomap({\n    \"vm-example-01\" = {\n      id       = 101\n      template = 9000\n    },\n    \"vm-example-02\" = {\n      id       = 102\n      template = 9022\n    },\n  })\n\n  node        = \"pve\"\n  vm_id       = each.value.id\n  vm_name     = each.key\n  template_id = each.value.template\n  ci_ssh_key  = \"~/.ssh/id_ed25519.pub\"\n}\n```\n\n\u003c/details\u003e\n\n- See [`examples/vm-clone`](./examples/vm-clone/main.tf) for full working examples.\n- See [`modules/vm-clone/README.md`](./modules/vm-clone/README.md#inputs) for a list of variables.\n\n## VM Template Module\n\n\u003cdetails\u003e\n  \u003csummary\u003eCode Example: Create VM Template\u003c/summary\u003e\n\n```HCL\nmodule \"ubuntu22\" {\n  source = \"github.com/trfore/terraform-bpg-proxmox//modules/vm-template\"\n\n  node = \"pve\"\n\n  # Image Variables\n  image_url                = \"https://cloud-images.ubuntu.com/releases/22.04/release-20240301/ubuntu-22.04-server-cloudimg-amd64.img\"\n  image_checksum           = \"fa2146bb04e505ef9ebfaff951cfa59514593c86c6cecd79317a8487a363ebc2\"\n  image_checksum_algorithm = \"sha256\"\n  image_overwrite          = false\n\n  # VM Template Variables\n  vm_id          = 9022\n  vm_name        = \"ubuntu22\"\n  description    = \"Terraform generated template on ${timestamp()}\"\n  tags           = [\"template\", \"ubuntu\"]\n}\n```\n\n\u003c/details\u003e\n\n- See [`examples/vm-template`](./examples/vm-template/main.tf) for full working examples.\n- See [`modules/vm-template/README.md`](./modules/vm-template/README.md#inputs) for a list of variables.\n\n## Proxmox API Token\n\n### Permission Requirements\n\n```sh Grant Terraform Access to Proxmox\n# create role in PVE 8\npveum role add Terraform -privs \"Datastore.Allocate \\\n  Datastore.AllocateSpace Datastore.AllocateTemplate \\\n  Datastore.Audit Pool.Allocate Sys.Audit Sys.Console Sys.Modify \\\n  SDN.Use VM.Allocate VM.Audit VM.Clone VM.Config.CDROM \\\n  VM.Config.Cloudinit VM.Config.CPU VM.Config.Disk VM.Config.HWType \\\n  VM.Config.Memory VM.Config.Network VM.Config.Options VM.Migrate \\\n  VM.Monitor VM.PowerMgmt User.Modify\"\n\n# create group\npveum group add terraform-users\n\n# add permissions\npveum acl modify /sdn/zones -group terraform-users -role Terraform\npveum acl modify /storage -group terraform-users -role Terraform\npveum acl modify /vms -group terraform-users -role Terraform\n\n# create user 'terraform'\npveum useradd terraform@pve -groups terraform-users\n\n# generate a token\npveum user token add terraform@pve token -privsep 0\n```\n\nFor the image and vm-template modules, downloading images on a PVE node requires `Datastore.AllocateTemplate`,\n`Sys.Audit` and `Sys.Modify` permission to the root directory, `/`.\n\n```sh\npveum acl modify / -group terraform-users -role Terraform\n```\n\n## License\n\nSee [LICENSE](LICENSE) for more information.\n\n## Author\n\nTaylor Fore (\u003chttps://github.com/trfore\u003e)\n\n### Additional Modules, Templates \u0026 Tools\n\n| Github Repo                 | Description                                                            |\n| --------------------------- | ---------------------------------------------------------------------- |\n| [packer-proxmox-templates]  | Collection of Packer Templates for Proxmox                             |\n| [proxmox-template-scripts]  | Collection of Bash Scripts to Download Images and Create PVE Templates |\n| [terraform-bpg-proxmox]     | Terraform Modules for the BPG Proxmox Provider                         |\n| [terraform-telmate-proxmox] | Terraform Modules for the Telmate Proxmox Provider                     |\n\n## References\n\nOpenTofu/Terraform:\n\n- [GitHub: BPG/Terraform-Provider-Proxmox]\n\nLinux Container Images:\n\n- [Linux Containers | LXC Images](https://images.linuxcontainers.org/images/)\n  - We suggesting using the cloud-init enabled images: `\u003cDISTRO\u003e/amd64/cloud/rootfs.tar.xz`.\n\nLinux VM Cloud Images:\n\n- [OpenStack: Cloud Images], collection of image links.\n- [CentOS Cloud Images]\n  - Default User: `centos`\n  - Use `CentOS-Stream-GenericCloud-X-latest.x86_64.qcow2`\n- [Debian Cloud Images]\n  - Default User: `debian`\n  - Use `debian-1x-generic-amd64.qcow2`\n  - Avoid:\n    - `genericcloud` images fail to run `cloud-init`\n    - `nocloud` images do not have `cloud-init` installed and defaults to a password-less `root` user.\n- [Fedora Cloud Images]\n  - Default User: `fedora`\n  - Use `Fedora-Cloud-Base-Generic.x86_64-XX-XX.qcow2`\n- [Ubuntu Cloud Images]\n  - Default User: `ubuntu`\n  - Use `ubuntu-2x.04-server-cloudimg-amd64.img`\n\n[Terraform]: https://github.com/hashicorp/terraform\n[OpenTofu]: https://opentofu.org/\n[Proxmox]: https://www.proxmox.com/\n[BPG Proxmox]: https://github.com/bpg/terraform-provider-proxmox\n[GitHub: BPG/Terraform-Provider-Proxmox]: https://github.com/bpg/terraform-provider-proxmox\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[packer-proxmox-templates]: https://github.com/trfore/packer-proxmox-templates\n[proxmox-template-scripts]: https://github.com/trfore/proxmox-template-scripts\n[terraform-bpg-proxmox]: https://github.com/trfore/terraform-bpg-proxmox\n[terraform-telmate-proxmox]: https://github.com/trfore/terraform-telmate-proxmox\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrfore%2Fterraform-bpg-proxmox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrfore%2Fterraform-bpg-proxmox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrfore%2Fterraform-bpg-proxmox/lists"}