packer-plugin-virtualbox icon indicating copy to clipboard operation
packer-plugin-virtualbox copied to clipboard

BUG: base_mac added to bundled Vagrantfiles is causing reuse of MAC addresses.

Open ladar opened this issue 3 years ago • 0 comments

Overview of the Issue

When export VirtualBox Vagrant images/boxes the snippet:

# The contents below were provided by the Packer Vagrant post-processor

Vagrant.configure("2") do |config|
  config.vm.base_mac = "0800273XXXXX"
end

Is included. When creating multiple boxes using the same base image, you end up with multiple guests getting the same MAC address, which causes obvious problems.

Setting config.vm.ignore_box_vagrantfile = true in the local Vagrantfile acts as a workaround.

Reproduction Steps

curl -LSso Vagrantfile https://raw.githubusercontent.com/lavabit/pahoehoe/4a02650059db4647af7a67f741b4c99c92de30ae/Vagrantfile
export VAGRANT_HOME="$(pwd)/vagrant.d/"
vagrant up --provider=virtualbox

grep base_mac vagrant.d/boxes/generic-VAGRANTSLASH-debian10/*/virtualbox/Vagrantfile
vboxmanage list vms | awk -F' ' '{print $1}' | tr -d '"' | while read NAME ; do vboxmanage showvminfo $NAME --details ; done | grep -i "NIC 1" | grep MAC | sed 's/, Attachment.*//g'

This will bring up two boxes based on the generic/debian10 image and one box based on generic/centos8. The output from vboxmanage/grep should show that both Debian 10 boxes were assigned the same MAC for NIC 1.

# grep base_mac vagrant.d/boxes/generic-VAGRANTSLASH-debian10/*/virtualbox/Vagrantfile
  config.vm.base_mac = "08002757C9C6"
# vboxmanage list vms | awk -F' ' '{print $1}' | tr -d '"' | while read NAME ; do vboxmanage showvminfo $NAME --details ; done | grep -i "NIC 1" | grep MAC | sed 's/, Attachment.*//g'
NIC 1:           MAC: 08002757C9C6
NIC 1:           MAC: 08002757C9C6
NIC 1:           MAC: 08002710DD87

Plugin and Packer version

Packer 1.8.0

Simplified Packer Buildfile

git clone https://github.com/lavabit/robox && cd robox
./robox.sh box generic-debian10-virtualbox

Operating system and Environment details

Vagrant 2.2.19 VirtualBox 5.2

ladar avatar May 02 '22 13:05 ladar