packer vagrant vmware-workstation mac address change

502 views
Skip to first unread message

Jeremy Miller

unread,
Mar 30, 2015, 12:34:00 PM3/30/15
to packe...@googlegroups.com

I'm using packer to build a Centos7 vmware-workstation box.  The packer process completes successfully with networking, however when I initialize the box with vagrant and bring it up, I see the mac address changing.  The network fails to start because the mac in ifcfig-eth0 matches the packer mac address, not the vagrant.

From the build process:
./vmware.log:2015-03-30T11:21:38.486-05:00| vmx| A115: ConfigDB: Setting ethernet0.generatedAddress = "00:0c:29:43:bd:b1"
./vmware.log:2015-03-30T11:21:38.486-05:00| vmx| I120: Ethernet0 MAC Address: 00:0c:29:43:bd:b1
./packer-vmware-iso.vmx:ethernet0.generatedAddress = "00:0c:29:43:bd:b1"

During the vagrant start:
==> default: Cloning VMware VM: 'packer_vmware-iso_vmware.box'. This can take some time...
 INFO vmware_driver: Cloning VM to /home/apprun/packer_projects/Centos7/.vagrant/machines/default/vmware_workstation/6d841a95-6ead-4226-9f4b-4015382d8d92
 INFO vmware_driver: VMX file: /home/apprun/packer_projects/Centos7/.vagrant/machines/default/vmware_workstation/6d841a95-6ead-4226-9f4b-4015382d8d92/packer-vmware-iso.vmx

$ grep generated /home/apprun/packer_projects/Centos7/.vagrant/machines/default/vmware_workstation/6d841a95-6ead-4226-9f4b-4015382d8d92/packer-vmware-iso.vmx
ethernet0.addresstype = "generated"
ethernet0.generatedAddress = "00:0c:29:0b:fa:e5"


My guess is that the vmware clone is causing the mac address change?  How do I prevent the mac address from changing?

The other issue I see is that every time I run a packer build, it is always using the same mac address: 00:0c:29:43:bd:b1.

Thanks

Alvaro Miranda Aguilera

unread,
Mar 30, 2015, 5:01:06 PM3/30/15
to packe...@googlegroups.com
Hello,

mac are meant to be unique, so in virtualization approach that mean
the template need to be ready to allow this change

This is what I did for RHEL7 beta:

https://github.com/kikitux/packer-vagrant-oracle/blob/master/packer/redhat7/packer-redhat7.json

"sed -i -e '/#UseDNS yes/a UseDNS no' /etc/ssh/sshd_config",
"for nic in /etc/sysconfig/network-scripts/ifcfg-p*; do sed -i
/HWADDR/d $nic; done"

For RHEL6/5

https://github.com/kikitux/packer-vagrant-oracle/blob/master/packer/redhat65/packer-vagrant-redhat65-2disk.json

"cp /etc/ssh/sshd_config /etc/ssh/sshd_config.ori",
"sed -i -e '/#UseDNS yes/a UseDNS no' /etc/ssh/sshd_config",
"for nic in /etc/sysconfig/network-scripts/ifcfg-eth*; do sed -i
/HWADDR/d $nic; done",
"[ -f /udev/rules.d/70-persistent-net.rules ] && rm
/etc/udev/rules.d/70-persistent-net.rules"
> --
> You received this message because you are subscribed to the Google Groups
> "Packer" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to packer-tool...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Jeremy Miller

unread,
Mar 30, 2015, 5:04:21 PM3/30/15
to packe...@googlegroups.com
Yes, so why does packer always use the same mac address?  Or are my settings incomplete?  Also, if packer is building the image with a specific mac address (even if it is always the same) why does the vagrant clone process change the mac address?

FWIW, this works fine with vbox, only vmware is exhibiting this behavior.  My template for both is the same wrt networking.

I also deleted the HWADDR line to get past the issue but this is a hack.

Thanks 

Alvaro Miranda Aguilera

unread,
Mar 30, 2015, 5:42:25 PM3/30/15
to packe...@googlegroups.com
is not a hack

vmware:
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2002767


On Tue, Mar 31, 2015 at 10:04 AM, Jeremy Miller
Reply all
Reply to author
Forward
0 new messages