bpg/terraform-provider-proxmox

Add support for Default dropdowns/empty config fields

Closed this issue · 5 comments

Is your feature request related to a problem? Please describe.
In the Proxmox web UI there is the ability to set many dropdowns to "Default", but that option doesn't seem to be present in this provider.

This change would make it so our terraform plans are more flexible in the future if any of the Proxmox cluster defaults change.

Here is a specific example:
The bios field currently requires that the user either select ovmf or seabios, but this is not the same thing as the default field in the Proxmox UI.

Generated manually from the Proxmox UI by choosing the "Default" BIOS dropdown (notice how there is no bios setting set):

# cat 101.conf | grep "bios:"

Generated via the terraform provider:

# cat 101.conf | grep "bios:"
bios: seabios

Here's a list of the config lines that I've found that are added by this provider but they will work with empty defaults:

bios: seabios
cpuunits: 1024
keyboard: en-us
onboot: 0
protection: 0
tablet: 1
template: 0
vga: memory=16,type=std

This list is most likely not exhaustive, but these are the ones that I noticed are different from what I would expect when manually creating a default VM via the Proxmox UI.

Describe the solution you'd like
I think the cleanest implementation would be to only set fields that are necessary and default to not even having an entry in the .conf file unless they are explicitly set by the user.

Describe alternatives you've considered
Alternatively I think it would be nice if the user could specify "Default" as an option for these fields, but it's not as clean as not adding entries to the .conf file.

Additional context
Proxmox Virtual Environment 8.2.7
Plugin version v0.66.1

bpg commented

Thanks for reporting @joshmcorreia -- I totally understand your concerns!

Unfortunately, there are technical limitations in how the current provider handles defaults. In a nutshell, the older Terraform SDK provides no good way to distinguish between ‘no value’ and a default value in configuration files. I’ve started issue #1231 to address the root cause and migrate the provider implementation to the new Plugin Framework, which will be quite a long journey. However, the early prototype shows some promising results :)

That makes sense. I can work around it for now 😄 Closing since it's a duplicate of #1304 and you're already working on #1231.

@bpg For what it's worth I just noticed that the machine argument doesn't add a line to the config file by default. Is that one special for some reason?

bpg commented

@bpg For what it's worth I just noticed that the machine argument doesn't add a line to the config file by default. Is that one special for some reason?

Yeah, it is handled differently, as PVE does not return the machine type if it's default when provider reads back the clone state.

Got it, thank you 👍🏼