Skip to content

Conversation

jmsnll
Copy link

@jmsnll jmsnll commented Aug 23, 2025

Introduces a sub-set of new resources to the Terraform provider for managing storage configurations.

I'm marking this pull request as a draft as I still need to add the documentation and acceptance tests, in addition to verifying some of the tfsdk/json/url tags are set correctly. Also I have been developing again Proxmox VE 9 so I'm not sure which fields (if any) are specific to that version.

There is currently an issue with the backups block, applying and being stored in the state, but not actually being set in the API. But I wanted to submit the PR for feedback, if it's also too large I'm happy to split it up to make it easier to review.

New Resources

I have added the following new resources:

  • proxmox_virtual_environment_storage_directory: Manages directory-based storage.
  • proxmox_virtual_environment_storage_lvm: Manages LVM storage pools.
  • proxmox_virtual_environment_storage_lvmthin: Manages LVM-thin pools.
  • proxmox_virtual_environment_storage_nfs: Manages NFS-based storage.
  • proxmox_virtual_environment_storage_cifs: Manages SMB/CIFS-based storage.
  • proxmox_virtual_environment_storage_zfspool: Manages ZFS pool storage.
  • proxmox_virtual_environment_storage_pbs: Manages Proxmox Backup Server (PBS) storage, including support for encryption keys.

Those that still need to be implemented:

  • proxmox_virtual_environment_storage_ceph
  • proxmox_virtual_environment_storage_esxi
  • proxmox_virtual_environment_storage_iscsi
  • proxmox_virtual_environment_storage_rbd
  • proxmox_virtual_environment_storage_btrfs – unsure as it's still a technical preview

Contributor's Note

  • I have added / updated documentation in /docs for any user-facing features or additions.
  • I have added / updated acceptance tests in /fwprovider/tests for any new or updated resources / data sources.
  • I have ran make example to verify that the change works as expected.

Proof of Work

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

Terraform will perform the following actions:

  # proxmox_virtual_environment_storage_directory.test_directory_storage will be created
  + resource "proxmox_virtual_environment_storage_directory" "test_directory_storage" {
      + content = [
          + "backup",
          + "iso",
          + "vztmpl",
        ]
      + disable = false
      + id      = "test-storage-dir"
      + nodes   = [
          + "node1",
        ]
      + path    = "/mnt/pve/terraform-test-storage"
      + shared  = true

      + backups {
          + keep_all   = false
          + keep_daily = 110
        }
    }

  # proxmox_virtual_environment_storage_lvm.test_lvm_storage will be created
  + resource "proxmox_virtual_environment_storage_lvm" "test_lvm_storage" {
      + content              = [
          + "images",
        ]
      + disable              = false
      + id                   = "PNY"
      + nodes                = []
      + shared               = false
      + volume_group         = "PNY"
      + wipe_removed_volumes = false
    }

  # proxmox_virtual_environment_storage_nfs.test_nfs_storage will be created
  + resource "proxmox_virtual_environment_storage_nfs" "test_nfs_storage" {
      + content = [
          + "iso",
          + "vztmpl",
        ]
      + disable = false
      + export  = "/volume1/vm-images"
      + id      = "terraform-nfs-vm-images"
      + nodes   = []
      + server  = "10.10.10.10"
      + shared  = true
    }

  # proxmox_virtual_environment_storage_pbs.test_pbs_storage will be created
  + resource "proxmox_virtual_environment_storage_pbs" "test_pbs_storage" {
      + content                    = [
          + "backup",
        ]
      + datastore                  = "terraform"
      + disable                    = false
      + encryption_key_fingerprint = (known after apply)
      + fingerprint                = "23:49:1a:63:67:dc:7f:f1:89:31:f1:4c:80:a6:0b:79:16:0c:f3:c8:ae:4a:7f:42:ad:50:ba:b4:66:16:6d:37"
      + generate_encryption_key    = true
      + generated_encryption_key   = (sensitive value)
      + id                         = "terraform-pbs-debugger"
      + nodes                      = []
      + password                   = (sensitive value)
      + server                     = "10.10.10.10"
      + shared                     = (known after apply)
      + username                   = "root@pam!terraform"
    }

  # proxmox_virtual_environment_storage_smb.test_smb_storage will be created
  + resource "proxmox_virtual_environment_storage_smb" "test_smb_storage" {
      + content      = [
          + "images",
        ]
      + disable      = false
      + id           = "test-storage-nfs"
      + nodes        = []
      + password     = (sensitive value)
      + server       = "10.10.10.10"
      + share        = "main"
      + shared       = true
      + subdirectory = "/example"
      + username     = "root"
    }

  # proxmox_virtual_environment_storage_zfspool.test_zfs_storage will be created
  + resource "proxmox_virtual_environment_storage_zfspool" "test_zfs_storage" {
      + blocksize      = "32k"
      + content        = [
          + "images",
        ]
      + disable        = false
      + id             = "terraform-zfs-test"
      + nodes          = []
      + shared         = false
      + thin_provision = true
      + zfs_pool       = "rpool"
    }

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

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

  Enter a value: yes

proxmox_virtual_environment_storage_lvm.test_lvm_storage: Creating...
proxmox_virtual_environment_storage_nfs.test_nfs_storage: Creating...
proxmox_virtual_environment_storage_smb.test_smb_storage: Creating...
proxmox_virtual_environment_storage_pbs.test_pbs_storage: Creating...
proxmox_virtual_environment_storage_zfspool.test_zfs_storage: Creating...
proxmox_virtual_environment_storage_directory.test_directory_storage: Creating...
proxmox_virtual_environment_storage_lvm.test_lvm_storage: Creation complete after 0s [id=PNY]
proxmox_virtual_environment_storage_zfspool.test_zfs_storage: Creation complete after 1s [id=terraform-zfs-test]
proxmox_virtual_environment_storage_nfs.test_nfs_storage: Creation complete after 1s [id=terraform-nfs-vm-images]
proxmox_virtual_environment_storage_smb.test_smb_storage: Creation complete after 1s [id=test-storage-nfs]
proxmox_virtual_environment_storage_directory.test_directory_storage: Creation complete after 2s [id=test-storage-dir]
proxmox_virtual_environment_storage_pbs.test_pbs_storage: Creation complete after 2s [id=terraform-pbs-debugger]

Apply complete! Resources: 6 added, 0 changed, 0 destroyed.    

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Relates #2101

- implement interfaces for creating/updating each type of storage
- common base fields are extracted and type embedded
- as are the backup fields, as not all storage methods support backups

Signed-off-by: James Neill <[email protected]>
jmsnll added 21 commits August 23, 2025 13:06
- still need to implement adding the backup definitions but the models are implemented
- this breaks `proxmoxtf/resource/file.go` as it was using the wrong storage client (should've been the node specific storage endpoint)

Signed-off-by: James Neill <[email protected]>
…ommon attrs

- shared field is always included, just some it's always enabled, so handle that now in the schema factory by denoting it as computed with a default of true

Signed-off-by: James Neill <[email protected]>
- supports automatic generation and management of encryption keys

Signed-off-by: James Neill <[email protected]>
@jmsnll jmsnll force-pushed the feat/support-cluster-storage branch from d1b140c to a9d1250 Compare August 23, 2025 11:10
@jmsnll jmsnll marked this pull request as draft August 23, 2025 11:19
…aform-provider-proxmox into feat/support-cluster-storage
@bpg
Copy link
Owner

bpg commented Aug 31, 2025

Thank you so much for adding this @jmsnll! ❤️

It will take some time to go over the code. Yeah, the PR is quite big, but I'm not sure if it will be much easier if we split it. Those resources are really close to each other, and you did a great job extracting generic pieces from them. So will review them together.

@jmsnll
Copy link
Author

jmsnll commented Sep 1, 2025

My pleasure @bpg! I will hopefully get an opportunity to finish this off this weekend all being well 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants