I've been working on creating development environments a while now and my current employer wants to have a quick way of setting up a development environment for the projects that we do.
Since I've worked with Vagrant before it befell to me to do the setting up of it all.
Vagrant is a tool that can make use of virtualisation software like Virtualbox or VMWare. It provides means to run the vm image (box) with a provisioned state specifically for your (development) needs.
I started by making use of packer. Packer allows me to setup a vagrant box in much less time than it would take me to if I used Vagrant itself for creating boxes.
Packer allows you to select the iso and the virtualisation software and also provides hooks to provision the box with the tools you would need to do your job once you start developing on the box within your project.
This provisioning is obviously the hard part and needs the play-rewind-repeat cycle to really put the stuff on the box that you want.
Let me tell you what I did without the repeat cuz of course I did it right in one time *cough*.
I found a set of packer templates on the web that allowed me to jumpstart the creation of the boxes.
Although I might now use PuPHPet with some adjustments I learned quite a bit about provisioning.
First the basics:
I modified the template I needed and I added an extra script for my provisioning needs.
I added this script in my template.json.
Then I added the puppet locations to my template.json within the provision section:
Obviously I have my build environment in tools/vagr_build as you can see here, you might have other locations.
I also make use of puppet-masterless because we do not have a puppet server within our company and I didn't want to invest time to set that up as well.
Now comes the big part, the real provisioning. I created my provisioning command in the default.pp file
I first install some base packages and mysql with apache. Then comes the PHP part and this part needed some extra configuration
To configure PHP correctly I needed to create a php.ini within /etc/php5/conf.d/ I updated its content using a tool called augeas Puppet knows how to use this but it needs to be installed serparately, so I did that with the base packages.
Note the context within a augeas part starts with /files/ this is a nessecary part to edit files.
From here I made my box file:
> packer build -only=virtualbox-iso .\template.json
and once this was done I did
> vagrant box add ubuntu_12_php53 .\ubuntu-12-04-x64-virtualbox.box
to place my box with vagrant
Later use of this box is just how you would normally use a vagrant box.