bpg / terraform-provider-proxmox

Terraform Provider for Proxmox
https://registry.terraform.io/providers/bpg/proxmox
Mozilla Public License 2.0
842 stars 138 forks source link

Allow Multiple DNS Servers for proxmox_virtual_environment_container and in vm template #816

Closed mkopnsrc closed 10 months ago

mkopnsrc commented 10 months ago

Is your feature request related to a problem? Please describe. Currently based on documentation and example, it only shows and supports single DNS server IP in the proxmox_virtual_environment_container dns -> server block. Normally everyone uses internal DNS servers rather then public DNS servers shown in example. Multiple DNS servers allows containers and VMs for failover DNS Resolve. image

Describe the solution you'd like A clear and concise description of what you want to happen. Please add the feature to allow multiple DNS servers in the server block as shown below. image

Describe alternatives you've considered Alternatively, when deploying container when no DNS server block provided it should automatically inherit the PVE Node Host DNS servers into container which is by default it's built-on feature within Proxmox VE.

Additional context None

mkopnsrc commented 10 months ago

Update on this issue,

It seems that you can have multiple DNS servers in a single string format with space in between, which it seem to worked for me. However, for the proper formatting of the values, it should be in object format.

image

Proxmox Release = 8.1 Proxmox Version = 8.1.3 Terraform Version = 1.6.6 Terraform Module = bpg/proxmox v0.40.0

bpg commented 10 months ago

Hi @mkopnsrc! 👋🏼

I think this is already supported, albeit not documented.

PVE does not provide an option to specify a list of DNS servers as separate items neither in UI, nor in APIs:

Screenshot 2023-12-17 at 9 27 38 PM Screenshot 2023-12-17 at 9 04 02 PM

But we can use a space-separated lists of IPs instead (tested with ubuntu cloud image):

 dns {
    domain = "example.com"
    server = "192.168.3.1 192.168.1.1"
  }
Screenshot 2023-12-17 at 9 25 33 PM

Then, on the VM itself:

ubuntu@test:~$ resolvectl status
Global
       Protocols: -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
resolv.conf mode: stub

Link 2 (eth0)
    Current Scopes: DNS
         Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
Current DNS Server: 192.168.3.1
       DNS Servers: 192.168.3.1 182.168.1.1
        DNS Domain: example.com
mkopnsrc commented 10 months ago

I appreciate your quick response, yes you're correct. Would be still possible to support the object based at the module level and when executing on PVE side, it would convert it to string format ?

The object level formatting on code would help admins to spot multiple entries easier and enables for comment for each DNS entries. Ex:

image

bpg commented 10 months ago

That would break backward compatibility with existing deployments. We could probably add a new attribute servers there, keeping the old server for compatibility.

bpg commented 10 months ago

@all-contributors please add @mkopnsrc for financial

allcontributors[bot] commented 10 months ago

@bpg

I've put up a pull request to add @mkopnsrc! :tada:

mkopnsrc commented 10 months ago

Thank you @bpg for your support.