1

I cloned a repo that included a Vagrantfile, a requirements file, and a few other things. I like the VM enough to want to re-use it for various projects, all of which would have their own repos. Rather than configuring each new repo's origin and removing extraneous files after cloning anew, I thought instead I could just make a copy of the VM and re-use it. So my basic workflow that I've pieced together would be this:

$ git clone https://github.com/.../x.git Template
$ cd Template
$ vagrant up
$ VBoxManage list vms
$ vagrant package --base Template_default_1394051969748_83660 --output ./template.box
$ vagrant box add template template.box virtualbox

Now I could just make a new directory for a project, run vagrant init, and then edit the Vagrantfile to use the template box.

My question is simply whether those who are more experienced in Vagrant think that I'm perhaps making this too hard or somehow missing the point of Vagrant.

Community
  • 1
  • 1
verbsintransit
  • 888
  • 3
  • 8
  • 18
  • 1
    The line between using provisioning and building a base box is not clear. In general, do what better fits your work flow and makes your live easier. I am using the most basic VM with nothing than the bare OS and have chef cookbooks which configure everything depending on the project. I know many who go the other way of having a "heavy" base box and just provision the stuff which depends on things outside the vm, like if it's windows/linux host or configuration depending on the IP assigned to the guest. – Sgoettschkes Mar 23 '14 at 21:01

1 Answers1

1

The answer depends on the modifications you have made to the base box, the time it takes to provision those modifications, the complexity of making the modifications, and the time the users of your modified boxes can afford to wait for provisioning on each "vagrant up --provision" request.

If your modifications are trivial and completed within seconds (e.g. your recipe run list is limited to the installation of a few, small public apps) then there is no need to create a new modified base box. If your changes are complex, time consuming, and perhaps require authentication credentials then perhaps you do provide value by pre-provisioning a modified base box.

The choice you make will likely vary from Vagrantfile to Vagrantfile.

To strive to honor the principle, you can declare the configuration of your modified, derivative base box with a packer specification. Ideally, you do not leave your users with a virtual machine that cannot be recreated if they lose access to your personal knowledge. Tailor your base box image with packer, create that modified box, and commit both the packer specification, the Vagrantfile, and the chef (or similar) provisioning scripts to change management.

Lonnie
  • 88
  • 1
  • 6