Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate mac address on two interfaces with cloud init processing #1000

Open
Raumy opened this issue May 2, 2024 · 3 comments
Open

Duplicate mac address on two interfaces with cloud init processing #1000

Raumy opened this issue May 2, 2024 · 3 comments
Assignees
Labels
bug upstream the problem needs to be (partially) fixed in an upstream library

Comments

@Raumy
Copy link

Raumy commented May 2, 2024

Hello,
Im' trying to create two VMs with a cloud init configuration. . I clone a template which has two network interfaces in the same bridge and in my configuration, I want to change the bridge for one interface.
Telmat provider 3.0.1-rc1
Proxmox 8.1.4

Here is the configuration file:

locals {
  vm_name          = "server"
  pve_node         = "pve"
  iso_storage_pool = "local-lvm"
}

resource "proxmox_vm_qemu" "vm" {
	count = 2
	name      = "${local.vm_name}-vm-${count.index + 1}"
	vmid = 100 + count.index + 1
	target_node = local.pve_node

	agent = 1
    clone       = "template1"
    os_type     = "cloud-init"
    cores       = 1
    sockets     = 1
    memory      = 512
    bootdisk    = "scsi0"
    scsihw      = "virtio-scsi-pci"
	cloudinit_cdrom_storage = "local-lvm"
	full_clone  = true
	boot                    = "order=scsi0;ide3"
	
	disks {
		scsi {
			scsi0 {
				disk {
					size               = 4
					storage            = "local-lvm"
				}
			}
		}
	}

	network {
		bridge = "vmbr0"
		model = "virtio"
	}
	network {
		model  = "virtio"
		bridge = "analyse"	
	}

    ipconfig0 = "ip=192.168.37.${count.index + 150}/24,gw=192.168.37.2"
    ipconfig1 = "ip=172.27.0.${count.index + 150}/24,gw=172.27.0.254"

    cicustom = "user=local:snippets/userconfig.yaml"
}

When the second VM is instantiated, the network interfaces have a different mac address but when the second interface switches to another bridge, it recovers the same mac address as the other interface, in fact the machine is unreachable and the creation process is in a loop.

Before changing the bridge :
prox_before

After changing the bridge :
prox_after

On the other hand, the first instantiated machine has two mac addresses and can be reached.

And we can see a cdrom drive on ide2 appears from nowhere....

Other information, when I instantiate only one machine, there is no problem, two different mac addresses, creation process which ends correctly.

Is there a way around the problem? Is this a configuration issue? A problem with the provider or with proxmox?

Thank you.

@Tinyblargon
Copy link
Collaborator

The ide2 will be fixed by RC2.
The problem of getting duplicate MAC addresses is a bug. Don't know if it's in the Terraform code or in the underlying library.

@Raumy
Copy link
Author

Raumy commented May 2, 2024

I've found a workaround by using terraform-provider-macaddress :
provider.tf

terraform {
  required_providers {
	proxmox = {
		source = "telmate/proxmox"
		version="3.0.1-rc1"
	}
    macaddress = {
      source = "ivoronin/macaddress"
      version = "0.3.0"
    }
  }
}

And my main.tf

locals {
  vm_name          = "server"
  pve_node         = "pve"
  iso_storage_pool = "local-lvm"
}
resource "macaddress" "mac_address_analyse" {
	count = 2
}
resource "proxmox_vm_qemu" "vm" {
	count = 2
	name      = "${local.vm_name}-vm-${count.index + 1}"
	vmid = 100 + count.index + 1
	target_node = local.pve_node

	agent = 1
    clone       = "template1"
    os_type     = "cloud-init"
    cores       = 1
    sockets     = 1
    memory      = 512
    bootdisk    = "scsi0"
    scsihw      = "virtio-scsi-pci"
	cloudinit_cdrom_storage = "local-lvm"
	
	boot                    = "order=scsi0;ide3"
	
	disks {
		scsi {
			scsi0 {
				disk {
					size               = 4
					storage            = "local-lvm"
				}
			}
		}
	}

	network {
		bridge = "vmbr0"
		model = "virtio"
	}
	network {
		model  = "virtio"
		bridge = "analyse"	
		macaddr = upper(macaddress.mac_address_analyse[count.index].address)
	}

     # Configuration des interfaces réseau
    ipconfig0 = "ip=192.168.37.${count.index + 150}/24,gw=192.168.37.2"
    ipconfig1 = "ip=172.27.0.${count.index + 150}/24,gw=172.27.0.254"

    # Configuration du fichier cloud-init
    cicustom = "user=local:snippets/userconfig.yaml"

}

The "apply" process terminate with "Apply complete!" and all VMs are reacheable.

@Tinyblargon
Copy link
Collaborator

@Tinyblargon Tinyblargon added the upstream the problem needs to be (partially) fixed in an upstream library label Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug upstream the problem needs to be (partially) fixed in an upstream library
Projects
None yet
Development

No branches or pull requests

2 participants