Skip to content

[PVE 9.x] Enabling std. APT repositories fails #2219

@alexander-zimmermann

Description

@alexander-zimmermann

Describe the bug

According to my understanding proxmox_virtual_environment_apt_standard_repository.example.file_path should point to /etc/apt/sources.list.d/proxmox.sources but it point to /etc/apt/sources.list

alexander@MAC-A43374-FHPWNP9X63:~/Development/homelab/infrastructure$ tofu state show module.pve_basics.proxmox_virtual_environment_apt_standard_repository.example
# module.pve_basics.proxmox_virtual_environment_apt_standard_repository.example:
resource "proxmox_virtual_environment_apt_standard_repository" "example" {
    description = "This is the recommended repository for testing and non-production use. Its packages are not as heavily tested and validated as the production ready enterprise repository. You don't need a subscription key to access this repository."
    file_path   = "/etc/apt/sources.list"
    handle      = "no-subscription"
    id          = "apt_standard_repository_pve_no_subscription"
    index       = 0
    name        = "No-Subscription"
    node        = "pve"
    status      = 1
}

To Reproduce
Steps to reproduce the behavior:

  1. Create the two resources as below.
  2. Run tofu apply.
  3. See error as below.

Please also provide a minimal Terraform configuration that reproduces the issue.

I follow the exmple from bpg/proxmox documentation to manage an APT standard repository of a Proxmox VE node.

resource "proxmox_virtual_environment_apt_standard_repository" "example" {
  handle = "no-subscription"
  node   = "pve"
}

resource "proxmox_virtual_environment_apt_repository" "example" {
  enabled   = true
  file_path = proxmox_virtual_environment_apt_standard_repository.example.file_path
  index     = proxmox_virtual_environment_apt_standard_repository.example.index
  node      = proxmox_virtual_environment_apt_standard_repository.example.node
}

and the output of terraform|tofu apply.


alexander@MAC-A43374-FHPWNP9X63:~/Development/homelab/infrastructure$ tofu apply
module.pve_basics.proxmox_virtual_environment_dns.this: Refreshing state... [id=pve_dns]
module.pve_basics.proxmox_virtual_environment_time.this: Refreshing state... [id=pve_time]
module.pve_user_acl["alexander"].proxmox_virtual_environment_user.this: Refreshing state... [id=alexander@pve]
module.ubuntu24.proxmox_virtual_environment_download_file.image: Refreshing state... [id=local:iso/ubuntu-24.04-cloudimg-amd64.img]
module.pve_basics.proxmox_virtual_environment_apt_standard_repository.enterprise: Refreshing state... [id=apt_standard_repository_pve_enterprise]
module.windows11.proxmox_virtual_environment_download_file.image: Refreshing state... [id=local:iso/windows-11-virtio.img]
module.debian12.proxmox_virtual_environment_download_file.image: Refreshing state... [id=local:iso/debian-12-generic-amd64.img]
module.pve_basics.proxmox_virtual_environment_apt_standard_repository.no_subscription: Refreshing state... [id=apt_standard_repository_pve_no_subscription]
module.lxc_ubuntu24.proxmox_virtual_environment_download_file.image: Refreshing state... [id=local:vztmpl/ubuntu-24.04-cloudimg-amd64-20250929.tar.xz]
module.pve_user_acl["alexander"].proxmox_virtual_environment_acl.this: Refreshing state... [id=/?alexander@pve?Administrator]

OpenTofu used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

OpenTofu will perform the following actions:

  # module.pve_basics.proxmox_virtual_environment_apt_repository.example will be created
  + resource "proxmox_virtual_environment_apt_repository" "example" {
      + comment       = (known after apply)
      + components    = (known after apply)
      + enabled       = true
      + file_path     = (known after apply)
      + file_type     = (known after apply)
      + id            = (known after apply)
      + index         = (known after apply)
      + node          = "pve"
      + package_types = (known after apply)
      + suites        = (known after apply)
      + uris          = (known after apply)
    }

  # module.pve_basics.proxmox_virtual_environment_apt_standard_repository.example will be created
  + resource "proxmox_virtual_environment_apt_standard_repository" "example" {
      + description = (known after apply)
      + file_path   = (known after apply)
      + handle      = "no-subscription"
      + id          = (known after apply)
      + index       = (known after apply)
      + name        = (known after apply)
      + node        = "pve"
      + status      = (known after apply)
    }

Plan: 2 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  OpenTofu will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

module.pve_basics.proxmox_virtual_environment_apt_standard_repository.example: Creating...
module.pve_basics.proxmox_virtual_environment_apt_standard_repository.example: Creation complete after 0s [id=apt_standard_repository_pve_no_subscription]
module.pve_basics.proxmox_virtual_environment_apt_repository.example: Creating...
╷
│ Error: Could not modify APT repository in file "/etc/apt/sources.list" at index 0 on node "pve"
│ 
│   with module.pve_basics.proxmox_virtual_environment_apt_repository.example,
│   on modules/pve_basics/main.tf line 35, in resource "proxmox_virtual_environment_apt_repository" "example":
│   35: resource "proxmox_virtual_environment_apt_repository" "example" {
│ 
│ modifying APT repository in file /etc/apt/sources.list at index 0 to activation state true: received an HTTP 500 response - Reason: invalid index - 0

Expected behavior
No error ;-)

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

  • Single or clustered Proxmox: single
  • Proxmox version: 9.0
  • Provider version (ideally it should be the latest version): 0.84.0
  • Terraform/OpenTofu version: 1.10.6
  • OS (where you run Terraform/OpenTofu from): MacOs Tahoe 26.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐛 bugSomething isn't working

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions