Using packer to build a Vagrant box

Background

So, Oracle Linux 7.4 was just released. Previously when a new version was released I downloaded it and manually installed it to see what the fuss was about (and to make sure you could actually install Oracle on it).

These days I tend to use Vagrant (as written about previously). But how do you build a Vagrant box?
You could of course do it the manual way, which means you click through the installation of the OS, then customize it to your hearts desire and finally export the VM as a Vagrant box, and that is fine. But as with all manual tasks, it gets tedious after a while.
I also tend to make the box look sort of the same every time (with the same extra packages installed and whatnot), so how do you easily automate this process?

Enter Packer, a tool to ‘Build Automated Machine Images’, as the slogan goes. Packer is built by Hashicorp (who also built Vagrant, Terraform and bunch of other awesome tools), and it helps you create identical images for a variety of different platforms using the same source configuration.

The source configuration in this case is a json file, which describes the builder (Virtualbox, Vmware, Amazon ec2 etc), and also have different types of provisioners that can be called (shell, Ansible, Chef, Puppet, Powershell) to further customize the image.

Continue reading

Advertisements