Open luclis opened 5 months ago
I must say I do not entirely know if this is more a libvirt bug, terraform-provider-libvirt bug or Packer bug. Even though that libvirt uses QEMU under the hood, I think it is safe to expect difference in usage by PAcker and libvirt.
What I can advise immediately is to try to replicate this bug with pure libvirt using virt-install
/virsh
. IF it happens, that's likely a libvirt bug rather than this provider one.
System Information
Linux distribution
Ubuntu 22.04
Terraform version
Checklist
Description of Issue/Question
When packaging a new vm with Packer over QEMU, the network interface use the ens4 name. When rebuilding it with Terraform, the network interface get the ens3 slot.
Setup
Steps to Reproduce Issue
variable "name" { sensitive = false default = "Debian-12.04" description = "The name of the firt VM created." }
variable "params" { sensitive = false default = { disk = "40960" format = "qcow2" ram = "4096" cpu = "2" } }
variable "accounts" { sensitive = true default = { username = "ansible" password = "ansible" } description = "The account of the first user." }
variable "iso" { default = { checksum = "file:https://cdimage.debian.org/mirror/cdimage/archive/12.4.0/amd64/iso-dvd/SHA256SUMS" url = "https://cdimage.debian.org/mirror/cdimage/archive/12.4.0/amd64/iso-dvd/debian-12.4.0-amd64-DVD-1.iso" } description = "The url of the iso." }
variable "guest_additions_iso" { default = { url = "https://download.virtualbox.org/virtualbox/6.1.50/VBoxGuestAdditions_6.1.50.iso" checksum = "file:https://download.virtualbox.org/virtualbox/{{.Version}}/SHA256SUMS" # Ne marche pas. Il prends pas le file on dirait. } description = "The url of the iso." }
variable "Port" { default = { min = 8081 max = 8081 } description = "The http server port. The value at min and max means only 1 port open." }
source qemu "Debian" { iso_url = var.iso.url iso_checksum = var.iso.checksum ssh_username= var.accounts.username ssh_password= var.accounts.password ssh_timeout= "30m" accelerator = "kvm" vm_name = var.name net_device = "virtio-net-pci" disk_interface = "virtio-scsi" disk_size = var.params.disk format = var.params.format memory = var.params.ram cpus = var.params.cpu
headless = true disk_compression = true
output_directory = "/srv/outputs/${var.name}" http_directory = "../../http" http_port_min = var.Port.min http_port_max = var.Port.max shutdown_command = "echo ${var.accounts.password} | sudo -S shutdown -P now" boot_command = [ "auto console-keymaps-at/keymap=fr url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg",
]
}
If you look at the packer build, the Ethernet and SCSI are inverted.
How to fix :
Workaround
net.ifnames=0 biosdevname=0
to set the interface name toeth0
.Thanks for your work, he's already amazing.