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

[BUG] MAC addresses re-generated on every run #37

Open
soakes opened this issue Aug 13, 2020 · 0 comments
Open

[BUG] MAC addresses re-generated on every run #37

soakes opened this issue Aug 13, 2020 · 0 comments

Comments

@soakes
Copy link

soakes commented Aug 13, 2020

Describe the bug

After initial creation of machine, if you re-run terraform apply, that even though the mac addresses are provisioned, will replace them with new ones as they are not defined in the config/manifest.

      ~ network_device {
            bridge      = "vmbr0"
            enabled     = true
          - mac_address = "9E:F9:DC:DE:62:E0" -> null
            model       = "virtio"
            rate_limit  = 0
            vlan_id     = 4001
        }
      ~ network_device {
            bridge      = "vmbr0"
            enabled     = true
          - mac_address = "7E:E0:C1:7D:32:F4" -> null
            model       = "virtio"
            rate_limit  = 0
            vlan_id     = 4002
        }
      ~ network_device {
            bridge      = "vmbr0"
            enabled     = true
          - mac_address = "12:A3:7C:E6:C0:B6" -> null
            model       = "virtio"
            rate_limit  = 0
            vlan_id     = 4003
        }
      ~ network_device {
            bridge      = "vmbr0"
            enabled     = true
          - mac_address = "B6:78:F8:71:85:6C" -> null
            model       = "virtio"
            rate_limit  = 0
            vlan_id     = 4004
        }
    }

To Reproduce
Run terraform twice with example code

provider "proxmox" {
  virtual_environment {
    endpoint = var.pm_api_url
    username = var.pm_user
    password = var.pm_password
    insecure = "false"
  }
}

resource "proxmox_virtual_environment_vm" "vm" {
  vm_id     = 27151
  pool_id   = "prod"
  count      = 1
  name = "testvm01"
  node_name = "pve01"
  cpu {
    cores = "2"
    sockets = "2"
  }
  clone {
    datastore_id = "prod-vm"
    vm_id = "2002"
  }
  disk {
    datastore_id = "prod-vm"
    size         =  30
  }
  memory {
    dedicated = 4096
  }
  agent {
    enabled = true
    trim    = true
  }

  initialization {
    datastore_id = "prod-vm"


    ip_config {
      ipv4 {
        address =  "172.27.1.50/24"
        gateway = "172.27.1.1"
      }
    }
    ip_config {
      ipv4 {
        address =  "172.27.2.50/24"
      }
    }
    ip_config {
      ipv4 {
        address =  "172.27.3.50/24"
      }
    }
    ip_config {
      ipv4 {
        address =  "172.27.4.50/24"
      }
    }
    user_account {
      keys     = ["${trimspace(var.ssh_public_key)}"]
      username = "root"
    }
  }

  network_device {
    vlan_id = "4001"
  }

  network_device {
    vlan_id = "4002"
  }

  network_device {
    vlan_id = "4003"
  }

  network_device {
    vlan_id = "4004"
  }

}

Expected behavior
If MAC address is already provisioned and known in the state file, it should then not regenerate MAC addresses. However if a mac address is defined in the config, then this should be used instead.

The only solution right now is to generate manually MAC addresses then encode them in the config or use lifecycle ignore.

Screenshots
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant