diff --git a/packer/macosx-10.10.json b/packer/macosx-10.10.json new file mode 100644 index 000000000..f18d2e249 --- /dev/null +++ b/packer/macosx-10.10.json @@ -0,0 +1,132 @@ +{ + "min_packer_version": "0.6.0", + "variables": { + "autologin_vagrant_user": "", + "iso_url": "./OSX_InstallESD_10.10.3_14D136.dmg", + "iso_checksum": "6d878aeb58aad23d2be00774d4da3b3d", + "iso_checksum_type": "md5", + "chef_version": "provisionerless" + }, + "provisioners": [ + { + "type": "file", + "destination": "/private/tmp/kcpassword", + "source": "scripts/macosx/support/kcpassword" + }, + { + "type": "shell", + "scripts": [ + "scripts/macosx/hostname.sh", + "scripts/macosx/builder.sh", + "scripts/macosx/add-network-interface-detection.sh", + "scripts/macosx/update.sh", + "scripts/macosx/vagrant.sh", + "scripts/macosx/cleanup.sh" + ], + "execute_command": "echo 'vagrant'| {{.Vars}} sudo -E -S sh '{{.Path}}'" + }, + { + "type": "shell", + "inline": [ + "[ -z \"{{user `autologin_vagrant_user`}}\" ] && exit", + "echo \"Enabling automatic GUI login for the 'vagrant' user..\"", + "cp /private/tmp/kcpassword /private/etc/kcpassword", + "/usr/bin/defaults write /Library/Preferences/com.apple.loginwindow autoLoginUser vagrant" + ], + "execute_command": "echo 'vagrant'| {{.Vars}} sudo -E -S sh '{{.Path}}'" + } + ], + "builders": [ + { + "boot_wait": "2s", + "disk_size": 20480, + "guest_os_type": "darwin12-64", + "iso_checksum": "{{user `iso_checksum`}}", + "iso_checksum_type": "md5", + "iso_url": "{{user `iso_url`}}", + "output_directory": "packer-macosx-10.10-vmware", + "shutdown_command": "echo 'vagrant'|sudo -S shutdown -h now", + "skip_compaction": true, + "ssh_password": "vagrant", + "ssh_port": 22, + "ssh_username": "vagrant", + "ssh_wait_timeout": "10000s", + "tools_upload_flavor": "darwin", + "tools_upload_path": "/Users/vagrant/{{.Flavor}}.iso", + "type": "vmware-iso", + "vm_name": "packer-macosx-10.10-vmware", + "vmx_data": { + "cpuid.coresPerSocket": "1", + "memsize": "2048", + "numvcpus": "1", + "firmware": "efi", + "keyboardAndMouseProfile": "macProfile", + "smc.present": "TRUE", + "hpet0.present": "TRUE", + "ich7m.present": "TRUE", + "ehci.present": "TRUE", + "usb.present": "TRUE" + } + }, + { + "boot_wait": "2s", + "disk_size": 20480, + "guest_additions_mode": "disable", + "guest_os_type": "MacOS109_64", + "hard_drive_interface": "sata", + "iso_checksum": "{{user `iso_checksum`}}", + "iso_checksum_type": "md5", + "iso_url": "{{user `iso_url`}}", + "output_directory": "packer-macosx-10.10-virtualbox", + "shutdown_command": "echo 'vagrant'|sudo -S shutdown -h now", + "ssh_password": "vagrant", + "ssh_port": 22, + "ssh_username": "vagrant", + "ssh_wait_timeout": "10000s", + "type": "virtualbox-iso", + "vm_name": "packer-macosx-10.10-virtualbox", + "vboxmanage": [ + ["modifyvm", "{{.Name}}", "--audiocontroller", "hda"], + ["modifyvm", "{{.Name}}", "--boot1", "dvd"], + ["modifyvm", "{{.Name}}", "--boot2", "disk"], + ["modifyvm", "{{.Name}}", "--chipset", "ich9"], + ["modifyvm", "{{.Name}}", "--cpus", "1"], + ["modifyvm", "{{.Name}}", "--firmware", "efi"], + ["modifyvm", "{{.Name}}", "--hpet", "on"], + ["modifyvm", "{{.Name}}", "--keyboard", "usb"], + ["modifyvm", "{{.Name}}", "--memory", "2048"], + ["modifyvm", "{{.Name}}", "--mouse", "usbtablet"], + ["modifyvm", "{{.Name}}", "--vram", "9"], + [ + "storageattach", "{{.Name}}", + "--storagectl", "SATA Controller", + "--port", "1", + "--type", "dvddrive", + "--medium", "{{user `iso_url`}}" + ] + ], + "vboxmanage_post": [ + [ + "storageattach", "{{.Name}}", + "--storagectl", "SATA Controller", + "--port", "1", + "--type", "dvddrive", + "--medium", "none" + ], + [ + "storagectl", "{{.Name}}", + "--name", "IDE Controller", + "--remove" + ] + ], + "virtualbox_version_file": ".vbox_version" + } + ], + "post-processors": [ + { + "type": "vagrant", + "vagrantfile_template": "vagrantfile_templates/macosx.rb", + "output": "../builds/{{.Provider}}/opscode_macosx-10.10_chef-{{user `chef_version`}}.box" + } + ] +} diff --git a/packer/scripts/macosx/add-network-interface-detection.sh b/packer/scripts/macosx/add-network-interface-detection.sh new file mode 100644 index 000000000..b38e52416 --- /dev/null +++ b/packer/scripts/macosx/add-network-interface-detection.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +# This script adds a Mac OS Launch Daemon, which runs every time the +# machine is booted. The daemon will re-detect the attached network +# interfaces. If this is not done, network devices may not work. +PLIST=/Library/LaunchDaemons/com.github.timsutton.osx-vm-templates.detectnewhardware.plist +cat < "${PLIST}" + + + + + Label + com.github.timsutton.osx-vm-templates.detectnewhardware + ProgramArguments + + /usr/sbin/networksetup + -detectnewhardware + + RunAtLoad + + + +EOF + +# These should be already set as follows, but since they're required +# in order to load properly, we set them explicitly. +/bin/chmod 644 "${PLIST}" +/usr/sbin/chown root:wheel "${PLIST}" diff --git a/packer/vagrantfile_templates/macosx.rb b/packer/vagrantfile_templates/macosx.rb index 9bf0fc693..8521f6656 100644 --- a/packer/vagrantfile_templates/macosx.rb +++ b/packer/vagrantfile_templates/macosx.rb @@ -1,4 +1,5 @@ Vagrant.configure('2') do |config| + config.ssh.insert_key = false config.vm.provider 'virtualbox' do |_, override| override.vm.synced_folder '.', '/vagrant', type: 'rsync' end