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

Only Libvirt - Version : 4.5.0 and Terraform - v0.11.10 supported network mode bridge #986

Open grandseba opened 1 year ago

grandseba commented 1 year ago

System Information

Linux distribution

Ubuntu.2204.

Terraform version

terraform -v >v0.11.10

Provider and libvirt versions > 4.5.0

terraform-provider-libvirt -version > 4.5.0

If that gives you "was not built correctly", get the Git commit hash from your local provider repository:

git describe --always --abbrev=40 --dirty

Checklist

Description of Issue/Question

Why only Libvirt - Version : 4.5.0 and Terraform - v0.11.10 supported network mode bridge ?

Setup

(Please provide the full main.tf file for reproducing the issue (Be sure to remove sensitive information)

Steps to Reproduce Issue

(Include debug logs if possible and relevant).


Additional information:

Do you have SELinux or Apparmor/Firewall enabled? Some special configuration? No special configuration, no SELinux and Apparmor is disabled Have you tried to reproduce the issue without them enabled?

jtackaberry commented 1 year ago

I am using tf v1.3.6 and terraform-provider-libvirt v0.7.0 (and libvirtd 6.0.0 on the server side) and had no trouble creating a direct bridge-mode network interface in a libvirt_domain, nor a bridge-mode libvirt_network resource.

grandseba commented 1 year ago

Ok, you can creating a direct bridge-mode but you can't set a lan adress ip .

LavBU commented 1 year ago

I am using tf v1.3.6 and terraform-provider-libvirt v0.7.0 (and libvirtd 6.0.0 on the server side) and had no trouble creating a direct bridge-mode network interface in a libvirt_domain, nor a bridge-mode libvirt_network resource. Hi @jtackaberry Can you please share your setting using bridge mode and network interface? My goal is to assign a static IP address to a new VM using bridge mode. I'm using these setting:

resource` "libvirt_network" "vm_public_network" {
  name = "${var.VM_HOSTNAME}_network"
  #mode = "nat"
  mode = "bridge"
  bridge = "br_v12"
  #domain = "${var.VM_HOSTNAME}.local"
  addresses = ["${var.VM_CIDR_RANGE}"]
  dhcp {
   enabled = false
  }
  dns {
   enabled = true
  }
}

resource "libvirt_domain" "vm" {
  count = var.VM_COUNT
  name = "${var.VM_HOSTNAME}-${count.index}"
  memory = var.VMEM
  vcpu = var.VCPU
  cloudinit = "${libvirt_cloudinit_disk.cloudinit.id}"
  qemu_agent = true
  network_interface {
    network_id = "${libvirt_network.vm_public_network.id}"
    network_name = "${libvirt_network.vm_public_network.name}"
    addresses      = ["${var.IP_MAIN}"]
  }
  console {
    type      = "pty"
    target_port = "0"
    target_type = "serial"
  }

  disk {
    volume_id = "${libvirt_volume.vm[count.index].id}"
  }

  graphics {
    type      = "spice"
    listen_type = "address"
    autoport   = true
  }
}

# cat network_config.cfg 
version: 2
ethernets:
  eth0:
     dhcp4: true

The result is that the VM is created but I can't ping to its IP. When using "nat" mode, it is working fine, but the host is the only one that can reach (ping/ssh) to the new VM. that is why I would like to use bridge mode.

Thanks, Lavi