packer_logo I recently wanted to update my Vagrant box running Debian Wheezy. The problem is, the box size is growing on each updates for several reasons. And I prefer to create a new box from scratch on any new Debian release.

Starting from scratch each time is a little bit boring, that’s why I created a preseed file (french). That made the install automatically, however I always had to do other step by hands (or need to write a script for it).

I remembered to have tested Packer a few times ago and decided to look at the features of the latest version.

The last one is good enough to make all I needed. So I started to write a Packer configuration file (on GitHub) and now I can build a Vagrant box ready in a few minutes in only one command!

Do you want to see? First clone the repository:

$ git clone https://github.com/deimosfr/packer-wheezy

Then edit _deimosfrdebian-wheezy file and adapt the variables fields with the Debian version you want and the ISO sha512 checksum:

"variables": {
        "debian_version": "7.6.0",
        "iso_checksum": "f8f0e2ddc5bafd5eb4188cca40a7e0acd12be3bb425ce5ad56734df6e807237e8798e61ac6bb07b02056ef7e7621ceba5f84c00449be449005f9c4e47055333f"
    },

Once done, create your box file:

$ packer build deimosfr_debian-wheezy

That’s it :-)

You can find the result on the vagrantcloud here if you only want to get the version built with it: https://vagrantcloud.com/deimosfr/debian-wheezy

Thanks HashiCorp for Vagrant and Packer :-)