dmacvicar / terraform-provider-libvirt

Terraform provider to provision infrastructure with Linux's KVM using libvirt
Apache License 2.0
1.59k stars 458 forks source link

Question: DHCP range in network resource ? #704

Closed magsoftware closed 4 years ago

magsoftware commented 4 years ago

Is it possible to define DHCP range in network resource ?

resource "libvirt_network" "kube_network" {
  name = "k8s-net"
  mode = "nat"
  addresses = [ "10.0.1.0/24" ]
  dhcp {
    enabled = true
  }
  dns {
    enabled = true
    local_only = true
  }
}

Somethin that will give eg:

    <dhcp>
      <range start='10.0.1.100' end='10.0.1.254'/>
    </dhcp>
MalloZup commented 4 years ago

@magsoftware hi. afaik we don't have it implemented upstream, unless i'm wrong.

but with the xslt feature you add it,

https://github.com/dmacvicar/terraform-provider-libvirt/blob/50a5506f6b29518f64ca74a9f22cd245be0c1fee/website/docs/r/network.markdown#altering-libvirts-generated-network-xml-definition

see : https://github.com/dmacvicar/terraform-provider-libvirt/blob/19c23424ccfdecf6dfcbdd87783bf835ba5f585e/examples/v0.12/xslt/main.tf#L5

MalloZup commented 4 years ago

other examples:

https://github.com/SUSE/ha-sap-terraform-deployments/blob/0ed22a718e76fac577eb5749de9a71fe5d9ad4e1/libvirt/modules/shared_disk/main.tf#L7

https://github.com/SUSE/ha-sap-terraform-deployments/blob/dc58fb1c0a702903aa66808f1b44d5fba2023a62/libvirt/modules/shared_disk/raw.xsl

magsoftware commented 4 years ago

Thanks. I did it with ansible. xslt is worse than assembler ;-)

MalloZup commented 4 years ago

OK closing. thx!