-
Notifications
You must be signed in to change notification settings - Fork 48
Vagrant
packer-template.json
is a stock template which can be used with packer to create a vagrant box using the vagrant-vmx
builder. To utilize a packer template, pass the -p
or --packer
argument with the path to packer-template.json
, or use a vfuse template. If you are using the packer-template.json
file from the repo, only the source_path
variable will be updated, otherwise a new generic packer-template.json
file will be generated.
- VMware Fusion 11.x Professional or above
- OS X 10.14+
- AutoDMG
- pycreateuserpkg OR MacUserGenerator
- Packer 1.1.1+
- Vagrant 1.7.2+
- Vagrant VMware Provider (purchase required)
- Outset
- Outset scripts
- Setup Resistant
(Vagrant by default assumes that your base image contains a user named vagrant
with ssh access and password-less sudo rights. See the vagrant docs for more info.)
Use pycreateuserpkg or MacUserGenerator to create a vagrant user.
Download outset and modify the outset scripts as you see fit and create a package with the included luggage Makefile or via whichever means you prefer.
Create a package to suppress the OS X Setup Assistant.
Launch AutoDMG and prepare your build.
Build your image
Now that you have a never-booted base dmg, use vfuse
to convert it to a VMware Fusion VM. First, clone the repo.
git clone [email protected]:chilcote/vfuse.git && cd vfuse
Make a copy of the template.json
file and edit to your needs.
cp -v template.json vagrant.json && vi vagrant.json
Here's the vagrant.json
template I used for this exercise:
{
"input": "~/Desktop/vagrant-10.10.3-14D136.dmg",
"output": "",
"name": "osx-vagrant",
"cache": false,
"hw_version": 11,
"mem_size": 4096,
"disk_type": "",
"bridged": false,
"packer_template": "packer-template.json"
}
Build your VM with vfuse
.
vfuse -t vagrant.json
You will see output indicating progress.
At this point, packer-template.json
should have been updated by vfuse
with the path of your VM. Now you can use packer to create the vagrant box. To help facilitate this, there are a few scripts in packer-scripts
(forked from Tim Sutton's osx-vm-templates scripts) in the current working directory that packer will reference. These scripts will install VMware Tools, Apple's Command Line Tools, puppet, chef, and optionally run software update.
The packer process will take quite a long time, since it launches the VM, runs these scripts, stops the VM, and compresses the disks.
Run packer with the build
argument to pass the template:
packer build ./packer-template.json
VMware Fusion will launch and you will see the VM loading. You can ignore this window.
You will see some fairly verbose output about what packer is doing. You can see it waiting for an ssh connection and then running the scripts in packer-scripts
.
After several minutes of output, you will have a file named packer_vmware-vmx_vmware.box
in the current directory.
Now that you have a vagrant box you can use, you can add it to your local vagrant boxes by using the box add
argument
vagrant box add osx103 packer_vmware-vmx_vmware.box
This process will also take several minutes.
Now you can launch your vagrant box by initializing a Vagrantfile (if you don't have a custom one) and bringing it up.
vagrant init osx103
vagrant up
If you're launching a 10.14 Mojave box, be sure to add this line to your Vagrantfile, or networking will not work: ssh_info_public = true