New vagrant basebox

New year, new development environment 😉

  • I want to have an environment that can be set up with “one click”.
  • I want to have an environment that is reusable for different projects
    and can be customized to fit different project needs.

What I’ll do is use vagrant with puppet to create the development environment and use hiera to make it easily customizable.

There’s some old post of mine where I started using vagrant with chef. That was some time ago and it looks like puppet is the one to chose over chef nowadays. The earlier decision to use chef was probably due to being hungry and liking the cookbook idea too much.

I also created my own basebox then, which is nice to know how it’s done but for usual purposes the standard Ubuntu 12.04 LTS box works just fine. Almost at least, I want to use puppet 3 on the basebox, so I’ll use a slightly altered version of hashicorp/precise32.

Caveat: vagrant new versions come up quite regularly, so you should check for new vagrant versions on a regular basis to keep the environment up to date. Current vagrant version is 1.7.2.

Download the base box:
vagrant box add hashicorp/precise32
This is a simple 64-bit Ubuntu 12.04 LTS box that has Chef/Puppet pre-installed.

Run vagrant init, adapt the Vagrant file to your needs, e.g. change the vm name. You’ll find the Vagrantfile I used at Do vagrant up, vagrant ssh and install whatever you thing you need on your basebox.

For example, to enable the repository for Ubuntu 12.04 Precise Pangolin:

  • wget
  • sudo dpkg -i puppetlabs-release-precise.deb
  • sudo apt-get update
  • sudo apt-get install puppet

NOTE: virtual machine will need a reboot to use the newly installed puppet version.

Make sure the virtualbox guest additions are installed on that box as well. You can either use a vagrant plugin named vagrant-vbguest that takes care of the guest additons for you
vagrant plugin install vagrant-vbguest or manually install the guest additions:

  • sudo apt-get install dkms
  • sudo apt-get install virtualbox virtualbox-qt virtualbox-dkms virtualbox-guest-dkms
  • sudo apt-get installlinux-headers-3.2.0-23-generic-pae
  • wget
  • mkdir ~/cdrom
  • cd cdrom
  • sudo ./

Either way, the vm now is larger as it needs be, no matter if you manually install the guest additions on the vm or use the vagrant plugin. The disk resizes when adding the guest additions but does not shrink automatically when deleting the guest additions iso image. I could try to resize it using zerofree but there’s other interesting stuff to be done.

NOTE: history -c erases the bash history, might come in handy before repackaging the box.

Repackage the box:
vagrant halt
vagrant package --base BOX_NAME --output
and add it to your boxes:
vagrant box add --name YOUR_BOX_NAME

Now we’re ready to start provisioning the vm, which will be the topic of the upcoming next post.

This entry was posted in howto, tools, virtual machine and tagged , , , . Bookmark the permalink.

Comments are closed.