I’m trying to create a network and bridge in KVM/Virsh (on Ubuntu 24.04) using Terraform. Is this possible? Or the bridge needs to be create before maybe using python prior? Thanks
I tried running this Terraform script.
terraform {
required_providers {
libvirt = {
source = "dmacvicar/libvirt"
version = "~> 0.7.6"
}
}
}
provider "libvirt" {
uri = "qemu+ssh://${var.user}@${var.hostip}/system?keyfile=${var.keyfile}&&sshauth=privkey" # Remote KVM host
}
resource "libvirt_network" "networks" {
count = length(var.networks)
bridge = var.networks[count.index].mode == "bridge" ? var.networks[count.index].bridge : null
name = var.networks[count.index].name
mode = var.networks[count.index].mode
addresses = [var.networks[count.index].address ]
autostart = true
}