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

Packer failing to get IP address on macOS 11 with VMware Fusion 12.0 #10177

Closed
trodemaster opened this issue Oct 27, 2020 · 9 comments · Fixed by #10384
Closed

Packer failing to get IP address on macOS 11 with VMware Fusion 12.0 #10177

trodemaster opened this issue Oct 27, 2020 · 9 comments · Fixed by #10384
Labels
bug builder/vmware stage/waiting-on-upstream This issue is waiting on an upstream change

Comments

@trodemaster
Copy link
Contributor

trodemaster commented Oct 27, 2020

Overview of the Issue

When using packer on macOS with VMware Fusion hypervisor the /var/db/vmware/vmnet-dhcpd-vmnet8.leases file is used to provide the guest OS IP address. Due to changes in macOS 11 (in beta as of today) VMware has adopted Apple provided hypervisor.framework and related networking stack. The end result with Fusion 12.0 is that the /var/db/vmware/vmnet-dhcpd-vmnet8.leases file is not populated and packer cant extract the needed IP address to configure the communicators.

I have opened a bug with VMware on this issue and waiting for details on how they will handle this change. Once I have guidance I will update this bug. If the dhcpd.conf file is going to be populated in a future version of Fusion then this issue will only exist for Fusion 12.0 on macOS 11. If going forward that file will not be used another method to determine the guest OS IP will be needed.

Reproduction Steps

Setup macOS 11 and install packer 1.6.4 and VMware Fusion 12.0. Use packer to build any template that uses ssh/winrm communicator. Note that the build hangs waiting for the vmnet-dhcpd-vmnet8.leases file to be populated. If you copy valid data into that file the packer build will continue as expected.

Packer version

1.6.4

Simplified Packer Buildfile

Confirmed the issue using this packer template https://github.com/trodemaster/packer-macOS-11 however any simple template that uses ssh or winrm will show the issue. This issue is not specific to any guest OS or template.

Operating system and Environment details

Host: macOS 11 Beta 10

Forum post noting this issue https://communities.vmware.com/thread/644271

@SwampDragons
Copy link
Contributor

Thanks for opening this -- looks like the VMware team have acknowledged in your post that this is an upstream bug, so I'll follow that issue for guidance too. If they don't get back to you soon I'll reach out internally through HashiCorp's partner channels.

@SwampDragons SwampDragons added builder/vmware stage/waiting-on-upstream This issue is waiting on an upstream change labels Oct 27, 2020
@alexpinheirosoares
Copy link

Ok, so this is not the prettiest workaround in any cases, here it goes:

  1. You start up your packer and it will perform then initial OS setup (silent install accordingly with your kickstart, pressed or unannatend.xml).
  2. Once your provisioners kick in, it will stay hanged trying to establish SSH (you need to increase your timeout)
  3. Open the Fusion Console on the VM that is creating, login and grab the mac address and ip address that the vm has.
  4. Go to /var/db/vmware and edit one of the .lease files you have there, adding the appropriate lease information (example below):
lease 192.168.108.4 {
	starts 2 2020/11/17 16:19:39;
	ends 2 2021/11/17 16:49:39;
	hardware ethernet 00:0c:29:4e:52:58;
	uid 01:00:0c:29:4e:52:58;
}
  1. Once you save the file, packer will detect the IP address and the provisioners will start.

I am not sure that the "change"/bug correction needs to occur on VMware side or at Packer side (which basically)!

@trodemaster
Copy link
Contributor Author

VMware has acknowledged the issue and I provided a functional solution to them. I imagine their focus is currently on releasing a build for Apple Silicon right now. I also have adopted creating a fake lease while we wait on a resolution.
https://github.com/trodemaster/packer-macOS-11/blob/main/scripts/fakelease.sh

@yerkanian
Copy link

yerkanian commented Dec 11, 2020

You can look up the MAC address in the /var/db/dhcpd_leases (managed by the new Apple DHCP server) on macOS 11 BigSur:

{ ip_address=192.168.191.4 hw_address=1,0:c:29:b0:9e:ae identifier=1,0:c:29:b0:9e:ae lease=0x5fd4a699 name=centos8 }

@trodemaster
Copy link
Contributor Author

Good find yerkanian! My recommendation is to update the packer code that searches for the IP address to check if the host OS is macOS version 11 or greater. If so then take the known mac address and search this /var/db/dhcpd_leases for the lease and related IP address. Also it's highly likely that other builders that start using hypervisor.framework will also benefit from this update.

@yerkanian
Copy link

The mac address will need to be zero-padded on BigSur before searching the file (/usr/sbin/arp also uses the same format for its output), not sure about the previous versions though.

@Pyrrvs
Copy link
Contributor

Pyrrvs commented Dec 13, 2020

I made a PR that seems to fix this issue. I was able to use Packer on my MBP with MacOS BigSur to generate a machine image.

@trodemaster
Copy link
Contributor Author

Thanks for the PR Pyrrvs! I have built packer with this PR and confirmed it's working for me. Host os is macOS 11.1RC. Here is the relevan log from my run.

https://gist.github.com/trodemaster/45c4d3bca4f0cc331520e043b1e6d8a3

@ghost
Copy link

ghost commented Jan 14, 2021

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked as resolved and limited conversation to collaborators Jan 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug builder/vmware stage/waiting-on-upstream This issue is waiting on an upstream change
Projects
None yet
5 participants