Skip to content

Commit

Permalink
add support for setting the network adapter MAC address (macaddr) and…
Browse files Browse the repository at this point in the history
… default it to 'repeatable'

- this is to work around an issue where duplicate addresses are generated
  • Loading branch information
greg committed Nov 26, 2023
1 parent 5dcbcf0 commit b406e81
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ As of November 2023, the following limitations and residuals have been observed:
configuration. Markdown is used in the description to try and make clear which
bit is configuration.

10. The Terraform provider Telmate/Proxmox can generate duplicate MAC addresses when
provisioning multiple VMs. IPv6 notices the duplicate/collision and doesn't complete
SLAAC, thus the VM doesn't get IPv6 addresses.

# Links

- https://austinsnerdythings.com/2021/09/01/how-to-deploy-vms-in-proxmox-with-terraform/
Expand Down
14 changes: 10 additions & 4 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -228,13 +228,19 @@ EOT
scsihw = "virtio-scsi-single"

// Support an array of virtio network adapters.
//
// If multiple VMs are created at the same time then the macaddr may be
// duplicated due to the time epoch being used to initialise the random
// seed (seen on Windows). Default to using the Telmate provider 'repeatable'
// option to generate a non-time based MAC address.
dynamic "network" {
for_each = var.networks
content {
model = "virtio"
bridge = lookup(network.value, "bridge", "vmbr0")
tag = lookup(network.value, "tag", null)
mtu = lookup(network.value, "mtu", null)
model = "virtio"
bridge = lookup(network.value, "bridge", "vmbr0")
tag = lookup(network.value, "tag", null)
mtu = lookup(network.value, "mtu", null)
macaddr = lookup(network.value, "macaddr", "repeatable")
}
}

Expand Down
7 changes: 4 additions & 3 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,10 @@ variable "memory" {
variable "networks" {
description = "An ordered list of network interfaces"
type = list(object({
bridge = optional(string, "vmbr0")
tag = optional(number)
mtu = optional(number)
bridge = optional(string, "vmbr0")
tag = optional(number)
mtu = optional(number)
macaddr = optional(string, "repeatable")
}))
default = [
{
Expand Down

0 comments on commit b406e81

Please sign in to comment.