Giter VIP home page Giter VIP logo

packer-templates's Introduction

mcandre/packer-templates: Configurations for generating Vagrant base boxes

VAGRANT CLOUD

https://app.vagrantup.com/mcandre

EXAMPLE

$ cd debian
$ time make install-box-virtualbox
packer build -force -only virtualbox-iso debian.json

...

      529.04 real        20.08 user        11.78 sys

vagrant box add -f --name mcandre/debian --provider virtualbox debian-virtualbox.box

...

$ vagrant box list
mcandre/debian                           (virtualbox, 0)

$ cd test
$ vagrant up
$ vagrant ssh -c 'uname -a'
Linux debian 4.9.0-4-amd64 #1 SMP Debian 4.9.51-1 (2017-09-28) x86_64 GNU/Linux
$ vagrant ssh -c 'ls /vagrant'
bootstrap.sh  flag.txt	Vagrantfile

REQUIREMENTS

Recommended

Note: Windows hosts are affected by a packer bug where attempts to kill a packer process by sending a Control+C signal, result in a half-dead packer that often awakes during subsequent builds, corrupting them. Task Manager is your friend.

General advice

  • Recommend 16 GB or more of guest disk space and 4 GB or more of guest RAM, to account for the girth of modern software development environments.

Providers/Hypervisors

Some packer templates support multiple hypervisor options. By default, Packer will attempt to target all configured hypervisors. Or, if you are interested in merely a subset of the hypervisors, ensure that the -only <comma,separated,providers> flag is specified to the packer build... command.

Regardless of provider, be sure to change directory to the guest OS desired (e.g. debian/), as Packer builds are relative to the current working directory, rather than relative to the packer JSON directory.

Note that many packer hypervisors deliver build keystrokes via host-timed keyup, keydown pairs. This means that if your host is overloaded (CPU, RAM, HD), then packer will deliver spurious keyboard activity to the VM during a build. In particular, this often looks like repeatttttttttttted keystrokes, as the keydown event is sent too slowly to faithfully execute the boot_command. So whichever machine is packing VMs should have sufficient spare capacity to build: few running applications, and plenty of CPU speed, RAM, and available HD space.

VirtualBox

One cleanup tip: As with all Vagrant hypervisors, VirtualBox sometimes leaves virtual machine data around when vagrant destroy [-f], or a signal interrupted vagrant up should have deleted these artifacts. When this happens, the user can launch the VirtualBox application and delete these files manually. VirtualBox will likely complain with multiple error prompts, but these can largely be ignored.

VMware

VMware boxes can be packed without a Vagrant plugin, but running the boxes to test them requires a paid license, even for users who have already paid for VMware. Go figure.

qemu/libvirt

qemu AKA libvirt boxes are fragile, requiring more care than VirtualBox or VMware providers. libvirt support for macOS hosts is nascent, so packing and running libvirt boxes is best performed from Linux hosts such as Debian, Ubuntu, or RHEL derivatives. qemu is slower than other hypervisors, especially when KVM is unavailable. This dramatically increases the time required for both packing and running qemu/libvirt boxes. Read: vagrant up --provider libvirt && vagrant ssh -c 'uname -a' for mcandre/debian takes several minutes, and packer build -only qemu debian.json takes over 3 hours. Speed demon!

The process for properly installing the vagrant-libvirt plugin is rather involved, requiring multiple separate packages to be setup. See the vagrant-libvirt README for more detail.

Once vagrant-libvirt is fully installed with native extensions, the host should be configured to avoid hibernation for at least 4 hours, in order to ensure that the packer build completes without network interruption.

In addition, libvirt requires additional manual configuration in order to correctly integrate with Vagrant via vagrant-libvirt:

  • The libvirt-bin and libvirt-guests services should be running. Consult your host operating system's init system.
  • The user running Vagrant must have sufficient permission to access the libvirt socket, such as adding the user to the libvirtd UNIX group.
  • Guest operating systems must name their network adapters according to the legacy Linux scheme in order to integrate with vagrant-libvirt and obtain an IP address. See fix-libvirt-networking.debian.sh in debian/ for an example GRUB configuration to enforce this policy in the guest OS at packing time.
  • libvirt may come preconfigured with extraneous networks and volumes that conflict with vagrant-libvirt. See virsh net-list and virsh vol-list --pool default to examine these resources.
  • Finally, some libvirt guests may do a poor job persisting file changes across vagrant package boundaries. To work around this limitation, ensure that the file system is explicitly synchronized at the end of provisioning scripts, e.g. sync in GNU/Linux.

TESTING

These boxes are designed as minimal bases for constructing build bot virtual machines, so that mcandre/tonixxx can use the boxes to conveniently cross-compile applications for many different kernels. The boxes are expected to feature:

  • working package manager, for installation of devopment tools like gcc, curl, lua, etc.
  • bidirectional-capable host->guest and guest->host synced folders, for copying source code to the box and copying artifacts back to the host.vagrant-rsync-back

The best way to ensure that the boxes are suitable for this development workflow is to attempt to install some package, and to check that files can be copied from the host and guest and back again. This workflow is automated in a testing script. Example:

$ cd debian/test
$ vagrant up
$ make test
...

packer-templates's People

Contributors

mcandre avatar strangelittlemonkey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

packer-templates's Issues

Add macOS

Success! We got a completely text-based automated install working:

bd89279

  • Test HGFS shared folders one more time.
  • Test cleanup scripts one more time.
  • Fix errors in cleanup scripts:
    vmware-iso: Password:rm: /Users/vagrant/payload: is a directory
2017/12/16 10:00:28 ui:     vmware-iso: Password:rm: /Users/vagrant/payload: is a directory
2017/12/16 10:00:28 ui:     vmware-iso: /System/Library/LaunchAgents/com.apple.safaridavclient.plist: Could not find specified service
    vmware-iso: /System/Library/LaunchAgents/com.apple.safaridavclient.plist: Could not find specified service
2017/12/16 10:00:28 ui:     vmware-iso: /System/Library/CoreServices/SafariSupport.bundle/Contents/Resources/com.apple.SafariBookmarksSyncAgent.plist: Could not find specified service
    vmware-iso: /System/Library/CoreServices/SafariSupport.bundle/Contents/Resources/com.apple.SafariBookmarksSyncAgent.plist: Could not find specified service
    vmware-iso: /System/Library/CoreServices/SafariSupport.bundle/Contents/Resources/com.apple.SafariHistoryServiceAgent.plist: Could not find specified service
2017/12/16 10:00:28 ui:     vmware-iso: /System/Library/CoreServices/SafariSupport.bundle/Contents/Resources/com.apple.SafariHistoryServiceAgent.plist: Could not find specified service
    vmware-iso: /System/Library/LaunchAgents/com.apple.Safari.SafeBrowsing.Service.plist: Could not find specified service
2017/12/16 10:00:28 ui:     vmware-iso: /System/Library/LaunchAgents/com.apple.Safari.SafeBrowsing.Service.plist: Could not find specified service
    vmware-iso: /System/Library/LaunchAgents/com.apple.notificationcenterui.plist: Could not find specified service
2017/12/16 10:00:28 ui:     vmware-iso: /System/Library/LaunchAgents/com.apple.notificationcenterui.plist: Could not find specified service
    vmware-iso: /System/Library/LaunchAgents/com.apple.IMLoggingAgent.plist: Could not find specified service
2017/12/16 10:00:28 ui:     vmware-iso: /System/Library/LaunchAgents/com.apple.IMLoggingAgent.plist: Could not find specified service
    vmware-iso: /System/Library/LaunchAgents/com.apple.CalendarAgent.plist: Could not find specified service
2017/12/16 10:00:28 ui:     vmware-iso: /System/Library/LaunchAgents/com.apple.CalendarAgent.plist: Could not find specified service
    vmware-iso: /System/Library/LaunchAgents/com.apple.AddressBook.AssistantService.plist: Could not find specified service
2017/12/16 10:00:28 ui:     vmware-iso: /System/Library/LaunchAgents/com.apple.AddressBook.AssistantService.plist: Could not find specified service
2017/12/16 10:00:28 ui:     vmware-iso: /System/Library/CoreServices/SafariSupport.bundle/Contents/Resources/com.apple.SafariLaunchAgent.plist: Could not find specified service
    vmware-iso: /System/Library/CoreServices/SafariSupport.bundle/Contents/Resources/com.apple.SafariLaunchAgent.plist: Could not find specified service
    vmware-iso: /System/Library/LaunchAgents/com.apple.AddressBook.ContactsAccountsService.plist: Could not find specified service
2017/12/16 10:00:28 ui:     vmware-iso: /System/Library/LaunchAgents/com.apple.AddressBook.ContactsAccountsService.plist: Could not find specified service
    vmware-iso: /System/Library/LaunchAgents/com.apple.icloud.fmfd.plist: Could not find specified service
2017/12/16 10:00:28 ui:     vmware-iso: /System/Library/LaunchAgents/com.apple.icloud.fmfd.plist: Could not find specified service
    vmware-iso: /System/Library/LaunchAgents/com.apple.cloudpaird.plist: Could not find specified service
2017/12/16 10:00:28 ui:     vmware-iso: /System/Library/LaunchAgents/com.apple.cloudpaird.plist: Could not find specified service
    vmware-iso: /System/Library/CoreServices/SafariSupport.bundle/Contents/Resources/com.apple.SafariCloudHistoryPushAgent.plist: Could not find specified service
2017/12/16 10:00:28 ui:     vmware-iso: /System/Library/CoreServices/SafariSupport.bundle/Contents/Resources/com.apple.SafariCloudHistoryPushAgent.plist: Could not find specified service
    vmware-iso: /System/Library/CoreServices/SafariSupport.bundle/Contents/Resources/com.apple.SafariPlugInUpdateNotifier.plist: Could not find specified service
2017/12/16 10:00:28 ui:     vmware-iso: /System/Library/CoreServices/SafariSupport.bundle/Contents/Resources/com.apple.SafariPlugInUpdateNotifier.plist: Could not find specified service
    vmware-iso: /System/Library/LaunchAgents/com.apple.imagent.plist: Could not find specified service
2017/12/16 10:00:28 ui:     vmware-iso: /System/Library/LaunchAgents/com.apple.imagent.plist: Could not find specified service
    vmware-iso: /System/Library/LaunchAgents/com.apple.AddressBook.abd.plist: Could not find specified service
2017/12/16 10:00:28 ui:     vmware-iso: /System/Library/LaunchAgents/com.apple.AddressBook.abd.plist: Could not find specified service
2017/12/16 10:00:28 ui:     vmware-iso: /System/Library/LaunchAgents/com.apple.Siri.agent.plist: Could not find specified service
    vmware-iso: /System/Library/LaunchAgents/com.apple.Siri.agent.plist: Could not find specified service
    vmware-iso: /System/Library/LaunchAgents/com.apple.icloud.findmydeviced.findmydevice-user-agent.plist: Could not find specified service
2017/12/16 10:00:28 ui:     vmware-iso: /System/Library/LaunchAgents/com.apple.icloud.findmydeviced.findmydevice-user-agent.plist: Could not find specified service
2017/12/16 10:00:28 ui:     vmware-iso: /System/Library/LaunchAgents/com.apple.cloudphotosd.plist: Could not find specified service
    vmware-iso: /System/Library/LaunchAgents/com.apple.cloudphotosd.plist: Could not find specified service
2017/12/16 10:00:28 ui:     vmware-iso: /System/Library/LaunchAgents/com.apple.touristd.plist: Could not find specified service
    vmware-iso: /System/Library/LaunchAgents/com.apple.touristd.plist: Could not find specified service
2017/12/16 10:00:28 ui:     vmware-iso: /System/Library/LaunchAgents/com.apple.iCloudUserNotifications.plist: Could not find specified service
    vmware-iso: /System/Library/LaunchAgents/com.apple.iCloudUserNotifications.plist: Could not find specified service
2017/12/16 10:00:28 ui:     vmware-iso: /System/Library/LaunchAgents/com.apple.cloudd.plist: Could not find specified service
    vmware-iso: /System/Library/LaunchAgents/com.apple.cloudd.plist: Could not find specified service
2017/12/16 10:00:28 ui:     vmware-iso: /System/Library/CoreServices/SafariSupport.bundle/Contents/Resources/com.apple.SafariNotificationAgent.plist: Could not find specified service
    vmware-iso: /System/Library/CoreServices/SafariSupport.bundle/Contents/Resources/com.apple.SafariNotificationAgent.plist: Could not find specified service
2017/12/16 10:00:28 ui:     vmware-iso: /System/Library/LaunchDaemons/com.apple.findmymacmessenger.plist: Could not find specified service
    vmware-iso: /System/Library/LaunchDaemons/com.apple.findmymacmessenger.plist: Could not find specified service
2017/12/16 10:00:28 ui:     vmware-iso: /System/Library/LaunchAgents/com.apple.AddressBook.SourceSync.plist: Could not find specified service
    vmware-iso: /System/Library/LaunchAgents/com.apple.AddressBook.SourceSync.plist: Could not find specified service
2017/12/16 10:00:28 ui:     vmware-iso: /System/Library/LaunchAgents/com.apple.siriknowledged.plist: Could not find specified service
    vmware-iso: /System/Library/LaunchAgents/com.apple.siriknowledged.plist: Could not find specified service

    vmware-iso: Started erase on disk1s1 Macintosh HD
2017/12/16 10:01:01 ui:     vmware-iso: Started erase on disk1s1 Macintosh HD
2017/12/16 10:01:01 ui:     vmware-iso: Creating a temporary file
    vmware-iso: Creating a temporary file
2017/12/16 10:01:02 ui:     vmware-iso: Securely erasing a file
    vmware-iso: Securely erasing a file
    vmware-iso: Creating a secondary temporary file
2017/12/16 10:02:16 ui:     vmware-iso: Creating a secondary temporary file
    vmware-iso: Mounting disk
2017/12/16 10:02:30 ui:     vmware-iso: Mounting disk
2017/12/16 10:02:30 ui:     vmware-iso: Finished erase on disk1s1 Macintosh HD
    vmware-iso: Finished erase on disk1s1 Macintosh HD
    vmware-iso: Partition / is not shrinkable
2017/12/16 10:02:30 ui:     vmware-iso: Partition / is not shrinkable
  • Credit Tim Sutton's repo for prior art.
  • Obtain an ISO and packer config that successfully boots into the graphical installer
  • Automate installation via text, by supplying PKG files into the ISO that preempt the graphical installer.
  • Fix or ignore launchd messages on boot. (Ignoring.)
  • Resolve blank gray screen boot. (By using the official createinstallmedia, configuring VirtualBox virtual hardware for a supported Apple device, and by waiting 30 seconds for SetupAssistant to load.)
  • Resolve UEFI boot menu. (By ensuring at least 5500MB for createinstallmedia disk.)
  • Try the ISO generating technique from timsutton/osx-vm-templates#82
  • Working around boot error with macOS 10.13 High Sierra by targeting macOS 10.12 Sierra instead.
  • Test entire boot_command
  • Test all provisioning scripts
  • Purchase VMware plugin for Vagrant.
  • Test Vagrant file upload, shell script provisioning.
  • Test shared folders.
  • Try navigating macOS installation via keyboard with packer boot_command. (Seems to work fairly well!)
  • Setup destination disk so that Disk Utility can see it. (Once in Disk Utility app, press Command+2 to view all devices.
  • Figure out how to select the View All Devices menu option in Disk Utility, and how to quit Disk Utility. (Use Control+F2, arrow keys, and spacebar to navigate application menus.)
  • Work around packer assumption of IBM scancodes, whereas macOS VM's use Apple keyboard scancodes. (Using VMware builder to work around scancode mismatch by sending key codes via VNC.)
  • Figure out how to select the install volume from SetupAssistant purely by keyboard. (Use Control+F2 keyboard navigation to access Terminal.app, enter launchctl kickstart system/com.apple.VoiceOver to enable VoiceOver, use Control+F2 again to quit Terminal.app, use arrow keys to launch macOS installer, spacebar and tab to navigate most of the UI, and then use the VoiceOver Control+Option+(arrow key) to select install target volume.
  • Fix boot loop after running macOS installer.
  • Fix boot loop in Windows 10. (Patch VMware with unlocker, specify smc.version = "0" in VMX, and specify cpuid.1.eax = "0000:0000:0000:0001:0000:0110:1010:0101" in VMX.)
  • Rerun packer build and ensure that the VoiceOver Option/Alt hotkeys are correctly being processed.
  • Fix Fusion boot loop halfway through installation. (vmware-iso builder was defaulting to SCSI interface for virtual hard drive. vmware-iso does not offer a standard way to specify SATA, but was able to disable the SCSI drive and enable a SATA connection to disk.vmdk via vmx_data.
  • Fix country selection. (Patched packer to recognize Super/Windows/Command keys.)
  • Fix "Express Setup" section of boot_command. (Use VoiceOver via packer patched with Super key support.)
  • Fix VoiceOver not fully progressing initial install (Appears to be a timing issue, so adding more <wait>s to delay before submitting keys.)
  • Fix shutdown command (echo password into the sudo command, authorizing a shutdown).
  • Fix shutdown command some more (specify -S flag to sudo so that the password is read from STDIN rather than a live user terminal connection).
  • Fix ssh service not launching at boot. (Reboot into Recovery Mode. Reconfigure the Disabled key in /Volumes/Macintosh HD/System/Library/LaunchDaemons/ssh.plist to false.)
  • Fix VoiceOver triggering the VoiceOver menu on VO-<arrow key> instead of navigating UI elements.
  • Fix Rescue Mode trigger. (Repeatedly send Command+R key down events with no key up for several minutes.)
  • Fix <rOn> missing during boot_command. (Evidently the key is being sent; the packer patch simply forgot to log this. The logging has been corrected.)
  • Fix Recovery Mode not rebooting into normal mode. (Reexamined the packer log, scrolled up. Realized that macOS was rebooting into normal mode and launching SSH. Apparently the provisioning scripts completed quickly enough that the output was overshadowed by the rest of the packer log completing the build.)
  • Fix sshd not launching (It was, though public key authentication was misconfigured.)
  • Fix ssh public key authentication. (Running sed -i '' 's/#PubkeyAuthentication yes/PubkeyAuthentication yes/' /etc/ssh/sshd_config during packing.)
  • Fix ssh timeout when connecting to the built box. (Working around public key misconfiguration by using password authentication method temporarily.)
  • Fix Vagrantfile customizations apparently not being applied to box on vagrant up. (They are.)
  • Fix sudo networksetup -detectnewhardware failing during darwin guest plugin setup. (Configured /etc/sudoers to not require a password for vagrant user sudo.)
  • Fix Terminal treated as damaged and unable to be opened. (Reran packer build.)
  • Fix VMware tools shared folders. (Enable kernel extension in Recovery Mode.)
  • Fix VMware tools installation media not appearing during packing. (Download during packing.)

Theories for fixing VMware tools installation media not appearing during packing:

Theories for fixing VMware tools shared folders:

  • Try rsync-based shared folders. (This workaround is sufficient, but I will continue to debug the HGFS method as it will hopefully be more efficient.)
  • Ensure VM is rebooted upon installing VMware tools.
  • Debug vmware tools install shell code.

Theories for fixing sudo command during darwin guest plugin setup:

  • Configure VM for password-less sudo during packing.

Theories for fixing public key configuration:

  • Examine the live VM for the contents of /Users/vagrant/.ssh/authorized_keys and file permissions up to root (/).
  • Check curl -o... syntax, specifically man curl as provided by default macOS.
  • Check public key file permissions.
  • Check file permissions for each parent directory from /Users/vagrant/.ssh up to root (/).

Theories for fixing Vagrantfile customizations being ignored:

  • Confirm test/Vagrantfile is being executed via print statements.
  • Confirm vmware-specific configuration is being executed via print statements.
  • Confirm file and directory structure are appropriate.
  • Confirm file and directory permissions are appropriate.

Theories for fixing ssh timeout when connecting to built box:

  • Configure config.vm.provider :vmare_fusion do |vmware| vmware.gui = true in Vagrantfile.
  • Use Recovery Mode to disable SIP, reboot into normal mode, enable sshd permanently, reboot into Recovery Mode, reenable SIP, reboot normally.
  • Configure Vagrant to launch graphical preview window to provide more
  • Check that sshd is being enabled for the right partition.
  • Insert wait between final reboot and ssh script provisioning
  • Confirm that /Volumes/Macintosh HD/System/Library/LaunchDaemons/ssh.plist in fact has Disabled configured as false at the end of boot_command.
  • Refer to prior art packer configuration for help configuring mac guest VM's for networking.
  • Increase boot timeout.
  • Override Vagrant networking configuration:
Vagrant.configure(2) do |config|
  config.vm.provider :vmare_fusion do |vmware|
    vmware.vmx["ethernet0.pcislotnumber"] = "33"
  end
end

Theories for fixing Recovery Mode not rebooting into normal mode:

  • Use menubar to reboot.

Theories for fixing missing <rOn> during boot_command:

  • Temporarily insert <leftSuperOn><rOn><wait5><rOff><leftSuperOff> at top of boot_command, check output of PACKER_LOG=1 packer build... for <rOn>, <rOff> presence.

Theories for fixing Rescue Mode trigger:

  • Test <rOn> again quickly with Ubuntu. Specificaly, test <leftSuperOn><rOn>.
  • Create a snapshot just before submitting sudo shutdown -r now, and time how long it takes to get to the pale VMware boot screen. Take several times to evaluate consistency (if any).
  • Try syncing to make reboot times more consistent.
  • Try preemptively killing certain processes to make reboot times more consistent.
  • Once shutdown is initiated, send repeated Command+R key down signals with no key up, for five minutes.

Theories for fixing VoiceOver menu:

  • Try different keyboard profiles.
  • Revert to old launchctl kickstart system/com.apple.VoiceOver method of enabling VoiceOver.
  • Revert packer A-Z hold patch.

Theories for fixing ssh service not launching at boot.

  • Patch packer to support holding down Super and A-Z keys, in order to trigger a boot into Recovery Mode during boot_command, so that /Volumes/Macintosh HD/System/Library/LaunchDaemons/ssh.plist can be edited without SIP interfering.
  • Practice timing the Command+R hotkey with plain VMware outside of packer.

See:

https://apple.stackexchange.com/a/300230

Theories for fixing Express Setup:

  • Use VMware snapshots to quickly determine an appropriate key sequence to progress Express Setup, using VoiceOver.

Theories for fixing country selection:

  • Try adding an appropriate number of <tab>s to the `boot_command

  • Speed up development by installing macOS 10.13 to a test VM, and sending keyboard keys via CLI over VNC.

  • Try pressing other keyboard keys

  • Try activating VoiceOver with Escape

  • Try committing country selection to disk after partitioning and before installing macOS.

  • Try activating VoiceOver via <leftAltOn><f5><leftAltOff>, hoping that Mac/PC VNC keyboard translation happens somewhere in good fortune.

  • Fork packer to recognize the Super key, at least for vmware-iso builds.

  • Install a launch daemon that forces VoiceOver to activate on boot, based on https://github.com/mcandre/dotfiles/blob/master/setenv.MOZ_DISABLE_SAFE_MODE_KEY.plist .

  • Fix Vagrant SSH public key missing (wget unavailable from fresh macOS install).

Theories for obtaining Vagrant SSH public key:

  • Manually echo the key contents
  • Install wget via Homebrew
  • Try using fetch (unavailable from standard macOS install)
  • Try using curl
  • Try using Ruby
  • Try using Python
  • Try using Perl

Theories for fixing boot loop in Fusion:

  • Compare packer effective VMX to known working manual Fusion VMX.

Theories for fixing boot loop in VMware Workstation Player in Windows on Apple hardware:

  • Compare VMX to the VMX on Gist.
  • Try using USB 2.0 virtual interface.

Unfortunately, the macOS 10.12 Sierra installation's timing is so erratic, either requiring ~30 minutes to complete, or else several hours, that there is little chance of boot_command succeeding.

  • Manually install macOS 10.12 Sierra.
  • Export OVF.
  • Use packer to complete Vagrant box.

Theories for fixing boot issues upon macOS installation:

  • Rerun packer build.
  • Rerun ISO generation.
  • Have diskutil repair /Volumes/Macintosh HD before installing macOS.
  • Use journaled HFS format instead of APFS.
  • Try configuring "smc.present": "FALSE" in VMX. (Causes macOS to stall during boot.)
  • Configure "guestCPUID.0": "00000001 000106e5 00100800 0098e3fd bfebfbff" in VMX.
  • Configure "cpuid.brandstring": "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc" in VMX.
  • Configure "smc.version": "0" in VMX.
  • Configure "sata0:2.present": "TRUE" in VMX.
  • Configure "ehci.pciSlotNumber": "34" in VMX.
  • Configure "usb.pciSlotNumber": "32", "usb:1.speed": "2", "usb:1.present": "TRUE", "usb:1.deviceType": "hub", "usb:1.port": "1", "usb:1.parent": "-1", "usb:0.present": "TRUE", "usb:0.deviceType": "hid", "usb:0.port": "0", "usb:0.parent": "-1" in VMX.
  • Configure "smbios.reflectHost": "FALSE" in VMX.
  • Configure "board-id.reflectHost": "FALSE", "board-id": "Mac-F2238BAE" in VMX.
  • Configure "hw.model.reflectHost": "FALSE", "hw.model": "iMac11,3" in VMX.
  • Configure dual cores in VMX.
  • Configure the hard drive as solid state in VMX. Identify the X and Y coordinates, then use the template "scsiX:Y.virtualSSD": "1".
  • After initial macOS install, before the first macOS target boots, disable SIP.
  • Manually install macOS in VirtualBox, add relevant configuration like cpuid, and see if that boots better.

http://www.insanelymac.com/forum/topic/309556-run-vanilla-os-x-el-capitan-sierra-or-high-sierra-in-vmware-workstation-12-on-a-windows-host/

Theories for fixing preseeding:

  • Configure "ethernet0.virtualDev": "e1000e" in VMX.

Theories for fixing macOS install error:

  • Increase RAM to at least 4096 MB.

https://www.jamf.com/jamf-nation/discussions/22731/in-place-macos-sierra-upgrade-script

Theories for installing macOS via Terminal:

  • Find the BaseSystem, InstallESD, and AppleDiagnostics DMG's.
  • Use installer to apply these DMG's to the target volume '/Volumes/Macintosh HD'

Theories for enabling VoiceOver via Terminal:

  • /System/Library/CoreServices/VoiceOver.app/Contents/MacOS/VoiceOver (Currently reports an error Someone has already checked in my running label. Exiting.
  • Hack the install ISO to include osascript. Then use osascript to activate VoiceOver.

Theories for fixing VoiceOver label:

  • Find and delete a *.pid or similar file.

Keyboard and mouse profile name candidates:

  • "windowsProfile"
  • "windows8Profile"
  • "windows10Profile"
  • "52559783-3576-1836-f8f7-d7d6c26c"
  • "528012fe-5e19-5990-f152-fea4aa11"
  • "520d3bb1-7ff1-2cc1-2d13-b4aeb9ed"
  • "5277983a-933b-b280-03db-d4137af3"
  • "52d1d410-5846-7f89-c532-2dc8a012"
  • "529767a2-56c6-806d-2b75-54536ebd"
  • "52bfd239-ee02-d3f9-bd90-9423c03c"

Theories for sending Command modifier:

  • Install macOS graphically, export as OVF. Use packer to continue provisioning OVF into a Vagrant box.
  • Modify install ISO so that VoiceOver is enabled by default.
  • Send raw Command+F5 scancode alongside packer in a carefully timed shell script.
  • Configure a PC keyboard and mouse profile with Left Alt (host) mapped to Command (guest).
  • Use the global menu bar to launch Terminal.app. At this point, hopefully VoiceOver can be enabled, or the installer can be launched from command line!

https://www.realvnc.com/en/connect/docs/mac-keyboard-mapping.html

https://pc.net/resources/shortcuts/mac_os_x

https://www.apple.com/voiceover/info/guide/_1124.html

Theories for working around scancode mismatch:

  • Write a polyglot boot_command whose IBM scancodes operate as Apple scancodes. For example, instead of using <down>, which packer maps to IBM scancode [0x50 0xd0], use b, which maps to IBM scancode [0x30 0xb0], which macOS would interpret as [0x30] => Down arrow, hopefully ignoring the 0xb0 as junk input and allowing for further keyboard keys. Not sure if the rest of the boot_command can be written in this way, and it's a pain to debug. If by some magic all the necessary keys for packing do have reasonably nice IBM equivalent scancodes, then a scancode mapping file could be written, and then a preprocessing step before packer build would involve applying github.com/hashicorp/packer/blob/master/builder/virtualbox/common's scancodes() over each command in the JSON boot_command array, emitting a polyglot, really screwed up looking packer.json to be generated that emits the desired scancodes to the macOS guest.
  • Find some way of setting up VirtualBox so that IBM scancodes are intercepted and translated to appropriate Apple scancodes.
  • Abandon boot_command and use VBoxManage controlvm "$VM" keyboardputscancode <hexpair> [<hexpair> [<hexpair> ...]]] to send raw scancodes to the macOS guest VM. Will need to find a way to space these out, simulating the behavior of <wait> in a normal packer boot_command string.
  • Replace the boot_command section with a script that runs parallel to packer -build, that sends appropriate keycodes, with sleep timers, to the VM.
  • Try vmware-iso builder, as it appears to rely on a more guest keyboard agnostic scancode mapping. https://github.com/hashicorp/packer/blob/master/builder/vmware/common/step_type_boot_command.go

Theories for intercepting and translating scancodes sent to VBoxManage:

  • File a ticket to configure scancode mappings, so that VBoxManage modifyvm <VM> --fromscancodes ibm --toscancodes apple or similar flags configure VirtualBox to automatically perform scancode translation between different scancode sets.
  • Write a bash script virtualbox-remap-scancodes-from-ibm-to-apple.sh with a function VBoxManage that intercepts IBM scancodes in VBoxManage controlvm "$VM" keyboardputscancode commands, maps them to Apple scancodes, and calls the real VBoxManage with the appropriate arguments.

Theories for spacing out VBoxManage controlvm "$VM" keyboardputscancode's:

  • Find some sort of VBoxManage sleep sub-command
  • Write VM's whose sole purpose is to sleep 1 second, 5 seconds, and 10 seconds, like boot_command's <wait>, <wait5>, <wait10>, and use VBoxManage commands to spin these up, wait for them to halt, and again.
  • Create an OVF with manual VBoxManage controlvm "$VM" keyboardputscancode and an export, and then use packer to complete the Vagrant box via the virtualbox-ovf builder.

http://www.comptechdoc.org/os/linux/howlinuxworks/linux_hlkeycodes.html

http://www.win.tue.nl/~aeb/linux/kbd/scancodes-1.html

https://github.com/phracker/MacOSX-SDKs/blob/master/MacOSX10.6.sdk/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/Headers/Events.h#L267-L315

https://apple.stackexchange.com/questions/258462/select-disk-destination-on-app-installation-with-keyboard

https://discussions.apple.com/thread/7024975?start=0&tstart=0

https://forums.macrumors.com/threads/how-to-install-os-x-without-mouse.1877784/

Prior Art:

https://github.com/timsutton/osx-vm-templates

https://github.com/nickcharlton/packer-osx

https://gist.github.com/agentsim/00cc38c693e7d0e1b36a2080870d955b

https://tylermade.net/2017/10/05/how-to-create-a-bootable-iso-image-of-macos-10-13-high-sierra-installer/

https://plus.google.com/+SysAdminsHowtos/posts/6e98eRghsw1

https://gist.github.com/julianxhokaxhiu/6ed6853f3223d0dd5fdffc4799b3a877

https://github.com/geerlingguy/macos-virtualbox-vm

https://github.com/MagerValp/SkipAppleSetupAssistant

http://macadminsdoc.readthedocs.io/en/master/General/macOS_Installation/Setup_Assistant.html

https://derflounder.wordpress.com/2014/11/21/controlling-the-diagnostics-usage-report-settings-on-yosemite/

http://www.amsys.co.uk/2015/01/creating-first-boot-script/

https://github.com/bacongravy/vagrant-box-macos

https://tickets.puppetlabs.com/browse/IMAGES-624

https://github.com/PureDarwin/PureDarwin/wiki/Live_CD

https://www.macworld.com/article/2018853/when-good-macs-go-bad-steps-to-take-when-your-mac-wont-start-up.html

https://gist.github.com/bzerangue/dca8fc2d63309ba2bd9f

http://www.hackmac.org/tutorials/crack-lion-password-hashes/

https://github.com/n0ts/veewee/tree/master/templates/OSX

https://github.com/jedi4ever/veewee/tree/master/templates/OSX

https://github.com/boxcutter/macos

https://auri.net/2016/11/20/how-to-setting-up-macos-x-sierra-on-virtualbox-for-xamarin-development-with-visual-studio/

https://www.tecklyfe.com/install-macos-sierra-10-12-virtualbox-windows/

https://github.com/timsutton/osx-vm-templates/pull/82/files

https://github.com/fnichol/packer-templates

Add Hyper-V provider

As a Windows user, I want more Hyper-V backed boxes, so I can run VM's more efficiently.

Pushed work in progress packer configuration for Hyper-V for Debian guest in a "hyper-v" branch.

Pending preseed HTTP server access from the guest in Hyper-V builds.

Pending Hyper-V providing a working virtual network interface for MINIX guests.

Debian: safe to remove other packages?

  • gcc-6-base (NO, a dependency of libstdc++6, which very many packages depend on)
  • cpp (via bsdmainutils)
  • wamerican (via task-english)
  • dictionaries-common (via task-english)
  • wireless-regdb (via task-laptop)

Shrink Debian box further

  • apt-get -y purge libx11-data xauth libxmuu1 libxcb1 libx11-6 libxext6
  • apt-get -y purge popularity-contest installation-report wireless-tools wpasupplicant
  • dpkg --list | awk '{ print $2 }' | grep -- '-dev$' | xargs apt-get -y purge
  • rm -f /home/vagrant/*.sh
  • unset HISTFILE && rm ~/.bash_history /home/vagrant/.bash_history
  • rm -f /root/.bash_history
  • rm /home/vagrant/.vbox_version
  • mkdir /etc/udev/rules.d/70-persistent-net.rules && rm /lib/udev/rules.d/75-persistent-net-generator.rules && rm -rf /dev/.udev/ /var/lib/dhcp3/* && echo "pre-up sleep 2" >> /etc/network/interfaces
  • rm /var/lib/dhcp/*
  • rm -rf rm -rf /usr/share/groff/* /usr/share/info/* /usr/share/lintian/* /usr/share/linda/*
  • find /var/log -type f | while read f; do echo -ne '' > $f; done
  • rm -rf /tmp/*
  • count=$(df --sync -kP / | tail -n1 | awk -F ' ' '{print $4}') && let count-- && dd if=/dev/zero of=/tmp/whitespace bs=1024 count=$count && rm /tmp/whitespace
  • count=$(df --sync -kP /boot | tail -n1 | awk -F ' ' '{print $4}') && let count-- && dd if=/dev/zero of=/boot/whitespace bs=1024 count=$count && rm /boot/whitespace
  • Wipe swap:
readonly swapuuid=$(/sbin/blkid -o value -l -s UUID -t TYPE=swap)
readonly swappart=$(readlink -f /dev/disk/by-uuid/"$swapuuid")
/sbin/swapoff "$swappart"
dd if=/dev/zero of="$swappart" bs=1M || echo "dd exit code $? is suppressed"
/sbin/mkswap -U "$swapuuid" "$swappart"
  • Use sed to configure UseDNS no in /etc/ssh/sshd_config
  • Use sed to change the GRUB_TIMEOUT from 5 to 0, then run update-grub

RHELs

Debian: remove ca-certificates

Because this package is very time sensitive, baking the package into the base box encourages downstream projects to be vulnerable by default.

Debian: remove man package, pages, and cache

  1. Uninstall the man-db package via apt-get.
find /usr/share/doc -depth -type f ! -name copyright|xargs rm || true
find /usr/share/doc -empty|xargs rmdir || true
rm -rf /usr/share/man/* /usr/share/groff/* /usr/share/info/*
rm -rf /usr/share/lintian/* /usr/share/linda/* /var/cache/man/*

Debian: try removing tcpd

Test that Vagrant ssh, ssh -c, shared folders, and both shell and file provisioning continue to function.

Automate uploading to Vagrant Cloud

As an engineer, I want box publishing to be streamlined, so I can work faster.

Based on https://stackoverflow.com/a/39414415/350106 , write a portable POSIX sh script that:

  1. Receives a Vagrant Cloud access token as an environment variable.
  2. Receives a namespaced public box name (e.g. mcandre/minix) as a CLI argument.
  3. Receives a box filename (e.g. minix-virtualbox.box) as a CLI argument.
  4. Obtains a second token for the upload.
  5. Uploads the box.
  6. Confirms the upload using that second token.

Or, use jq to inject a Vagrant Cloud post-processor https://www.packer.io/docs/post-processors/vagrant-cloud.html for some packer builds, but not by default, so that users without permission to upload these boxes can still reliably run packer build 100% sucessfully.

Separate cleanup commands into reuseable scripts

As a developer, I want to package cleanup scripts for reuse, so I can develop faster.

  • Separate cleanup commands into distinct scripts.
  • Organize scripts for reuse, minimizing the number of copies used across the different packer directories.

Add Windows

TODO:

  • Fix config.vm.provision "shell", path: "bootstrap.ps1" in test Vagrantfile
  • Promote config.vm.communicator = "winrm" to a Vagrantfile template for packer
  • Have OpenSSH installed and configured during packer, in preparation for vagrant ssh.
  • Finish testing bidirectional sync.
  • Ensure vagrant ssh -c '...' works
  • Promote config.vm.synced_folder ".", "/cygdrive/c/vagrant", type: "rsync" to Vagrantfile template for packer.

Theories for fixing various Windows guest issues:

  • Add bash.exe to PATH to workaround hardcoded bash -l limitation for vagrant ssh -c ...
  • Explicitly configure the base box as a Windows guest.

Theories for installing bash.exe:

  • Install git and ensure that bash.exe is in PATH.
  • Install and setup bash on Ubuntu on Windows AKA Windows Linux Subsystem.

Examples:

https://github.com/lwieske/packer-windows2016-core/blob/master/windows2016-core.json

https://github.com/rgl/windows-2016-vagrant/blob/master/windows-core-insider-2016.json

https://github.com/mwrock/packer-templates/blob/master/vbox-2016.json

https://github.com/joefitzgerald/packer-windows/blob/master/windows_10.json

https://github.com/boxcutter/windows

https://github.com/gildas/packer-windows/blob/master/templates/cic/packer.json

Shrink FreeBSD

  • Zero out all mounts
  • Clear package cache
  • Delete temporary files
  • Zero log files
  • Try using FreeBSD in VirtualBox without the virtualbox-ose-additions package. We're running headless, so any way to reduce clutter like X11, LLVM, Perl, and Python would be solid for saving disk space.

Add DragonFly BSD

Use freebsd.json and https://github.com/b00ga/packer-templates as templates for writing a DragonFly BSD packer configuration.

  • Enable shared folders by default.
  • Fix vagrant ssh -c 'ls [...]' freezing. (Not sure why it was broken, but fortunately rerunning Packer fixed this.)

DEBIAN_FRONTEND=noninteractive

Have export DEBIAN_FRONTEND=noninteractive defined prior to all apt-get commands, including install, remove, and purge, in each individual shell script that runs any apt-get commands.

Add NetBSD

  • Specify a moderate amount of RAM (1024MB) and disk space (8GB) towards installing clang++, rust + cargo. Later increase if necessary.
  • Work around passwd vagrant reading from tty device instead of stdin. (Feed the output of pwhash of the password into usermod -p.
  • Fix sshd connectivity by ensuring that dhcpcd is enabled in /etc/rc.conf.
  • Fix default shell (should be sh).
  • Fix Vagrant synced folders. (Configure vagrantfile_template for config.ssh.sudo_command = "su -l root -c '%c'" and add sudo shim.)
  • Fix shell provisioner / bootstrap.sh script. (use pkg_add to install wget).

Theories for working around passwd vagrant reading from tty device instead of stdin:

  • man passwd, search for configuration to force stdin. (Unfortunately, NetBSD's passwd lacks the --stdin flag.
  • Use usermod -p.
  • Use printf... to supply passwords.
  • Move passwd commands to boot_command (prefer not to as this slows down the build).

Use freebsd/ as a starting point.

See also:

https://github.com/boxcutter/bsd

https://github.com/upperstream/packer-templates

https://github.com/stoned/packer-nbsd-boxes/blob/master/netbsd-7-amd64.json

Add qemu AKA libvirt provider

Work in progress code pushed to qemu branch. Unfortunately, the vagrant-libvirt plugin is very broken in macOS, so it's difficult to test this.

May setup Vagrant inside Linux or Windows in order to work around this limitation (!)

Add more providers for FreeBSD

As a user, I want more backend providers, so I can use the right backend for my particular host configuration.

  • VMware
  • qemu
  • Hyper-V

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.