dmacvicar / terraform-provider-libvirt

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

[Feature request] ability to define several network interfaces to 1 container ( br0 to ens3f0 and br1 to ens3f1 etc. ) #959

Closed blinkinglight closed 1 year ago

blinkinglight commented 1 year ago

example xml:

    <interface type='bridge'>
      <mac address='00:60:2f:54:af:05'/>
      <source bridge='br0'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <interface type='bridge'>
      <mac address='00:60:2f:54:af:06'/>
      <source bridge='docker0'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x1'/>
    </interface>
blinkinglight commented 1 year ago

found that network_interface is typeList so i can have several networks.

resource "libvirt_network" "bridge1" {
  name = "bridge1"
  mode = "bridge"
  addresses = [ "192.168.250.5/24" ]
  bridge = "br0"
  autostart = true
}
resource "libvirt_network" "bridge2" {
  name = "bridge2"
  mode = "bridge"
  addresses = [ "192.168.251.5/24" ]
  bridge = "docker0"
  autostart = true
}

and in domain:

resource "libvirt_domain" "test" {
  name = "test"
  memory = 4096
  vcpu = 2
  network_interface {
      network_name = "bridge1"
  }
  network_interface {
      network_name = "bridge2"
  }
}

so, closing this.