26 5 / 2013

27 6 / 2012

30 5 / 2012

In my previous post I made some use of Librarian with Vagrant, a really nice combo tools to manage virtualization and provisioning with VirtualBox and Chef-solo.

But I went further in my automation crave madness by using the Cheffile and Vagrantfile to provision an EC2 instance.

What didn’t work for me

I were looking for an easy solution to provision an EC2 instance with Chef-solo and the cookbooks already used in my Vagrantfile.

I came across vagrant-ec2-r which is a fork of vagrant-ec2.

I encountered an issue with vagrant-ec2-r but also present in vagrant-ec2, cookbooks dependencies weren’t included into the tarball.

I first thought of fork and solve this problem but instead I had the idea to rely on Librarian and the Cheffile to avoid taking care of the annoying tarball and the cookbooks.


Inspired by vagrant-ec2 I came with Librarian-ec2 which is dead simple. Code could be found on github.com/nrako/librarian-ec2.

Librarian-ec2 revolves around 2 shell scripts:

  • Boostrap.sh: to be executed on the EC2 instance to install Chef-solo and Librarian.
  • Setup.sh: which take for arguments the ip of the instance, the path to the Vagrantfile/Cheffile and the keypair associated with the EC2 instance.

Librarian-ec2 Setup.sh:

  1. Create the dna.json which describe the recipes to be run by chef-solo.
  2. Secure copy scp the Cheffile and the dna.json file to the EC2 Instance.
  3. Run librarian-chef install on the EC2 instance to download the recipes and dependencies described by the Cheffile.
  4. Run chef-solo with dna.json and the cookbooks as arguments.

It’s inspired by vagrant-ec2 but rely on Librarian to retrieve the cookbooks instead of building a tarball which may be incomplete with cookbooks using dependencies.

Go read the README and fork it ;) github.com/nrako/librarian-ec2

17 5 / 2012

I drafted a long boring post commenting my one month experience with my first Mac. Trying to explain why as a Web Developer who used to works on Windows and Linux I was delighted of my switch. But the results was exceedingly dull and uninteresting. So instead I’ll go with a gif, because gifs are always uber-cool! ;)

some credits to running a startup

14 5 / 2012

14 5 / 2012

"If you are not embarrassed by the first version of your product, you’ve launched too late."

Reid Hoffman - via swiss-miss

03 5 / 2012

In the previous post, I or maybe we, builded a Vagrant base box for Ubuntu server 12.04 LTS.

That ubuntu-precise-64 box provides the base VM which is now to be provisioned. Provisioning is a crucial part of a managed deployment, If you don’t know what provisioning involves, please consider reading the Vagrant "Get started" guide.

Provisioning is a piece of cake with vagrant but It took me some time to figure out how to properly set up the provisioning scripts (recipes) from a developer standpoint – so I’m sharing my notes.

Pull the string or do some cooking?

Vagrant support either Puppet Manifests and Chef Cookbooks and both are supported in standalone (decentralized) or with a server.

For my needs I will rely solely on Chef solo (standalone) which seems the easiest way to quickly get the job done for a solo developer. Chef server seems excessive for my developer needs and Puppet seems very powerful but a bit more complicate than Chef solo, maybe I’m wrong if so please comment.

Manages the cookbooks recipes

At first I had some trouble to figure out how I should store and manage my cookbooks.

I thought about creating a new git repository where my cookbooks would have been maintained. But the unavoidable need to manage the recipes versions overtime bothered me, and that could potentially create conflicts between my projects. Storing the cookbooks directly into the project git repo would have solved conflicts but then I would have to maintain a lot more recipes over many cookbooks – that can’t be the solution.

Then I looked into Chef server and knife, but that involved to much hassle for my abilities and I think that didn’t really fulfilled my needs either, if I’m wrong again comment.

What I wanted was something simple like a proper package manager tool, like npm, package.json and node_modules or gembundler and Gemfile for the rubyist. A developer tool which is quick and easy to install and manage and moreover a tool that could take care of the versions and the dependencies for me.

After some research on stackoverflow I found Librarian-chef which was exactly what I needed.


The Librarian README is well detailed and concise so I wont bother with the details but if you already use npm or other proper package manager tool this should seems very familiar.

Install librarian:

$ gem install librarian

Into the folder where the Vagrantfile is located run the init command:

$ librarian-chef init

Verify the existence of the Cheffile with the cat command:

$ cat Cheffile

Now we need to works on the Cheffile to add the desired recipes into our cookbooks.

For example add the following line in the Cheffile or uncomment if already present:

cookbook 'apache2', '>= 1.0.0'

This tell librarian-chef that we want the recipe for apache2 and at least in version 1.0.0.

Then run the install command:

$ librarian-chef install

That command fetch the most recent apache2 recipe and store it into the cookbooks directory. In this case Librarian will look into the default recommended source, the Opscode Community Site API which is the default source defined by the site variable in the Cheffile.

site 'http://community.opscode.com/api/v1'

Of course you could define the source for each recipe from a git repo url or path in order to use your own cookbooks. Just take a look into the Librarian README.

HINT : Be careful the install command recreate the entire cookbooks directory, instead what you may also need is in the Librarian README, search about the outdated and update commands.

Librarian-chef conclusion

Librarian is awesome, it help to avoid all the burden that would normally exists if we had to manage all recipes and versions manually. It provides an easy way to define, fetch and maintain our recipes with just a single file and the cli. As I wrote earlier if you are already familiar with any package manager tool like npm or gembundler you probably noticed the similarities – Cheffile look either like the dependencies section of a package.json file or like a Gemfile, exactly what I wanted!

Configuring Vagrant

We still have to tell Vagrant to use our Chef cookbooks for the provisioning.

Edit the Vagrantfile and modifiy your code to have the config.vm.provision section looking like this:

config.vm.provision :chef_solo do |chef|
  chef.add_recipe "apache2"

This tell Vagrant to use the apache2 Chef recipe, by default Vagrant will look into the cookbooks folder so you will only need those 3 lines, but it’s still up to you to relocate your cookbooks directory and redefine the path to point the new location.

To load the VM with this recipe run the vagrant reload command:

$ vagrant reload

Or run the vagrant up command if you don’t already have the VM created:

$ vagrant up

Results, Ubuntu Precise Pangolin 12.04 64bit deployed with apache2 automatically installed.

Obviously vagrant, chef, and librarian are indispensables tools for a developer arsenal but moreover for a team who can now easily shares the same exact environment.

Now we are good for the development side, but is there a way to use that for production? Could an Amazon EC2 instance be provisioned with our current config tools? You bet! After few searches for vain solutions I came with two shell scripts which will perform provisioning to an EC2 instance from the Cheffile and the Vagrantfile, go read From Vagrant & Librarian to EC2.

03 5 / 2012

Managing a development environment is a tedious task – of course you already rely on VMs if you aren’t maybe you should start here – but installing the os and the whole stack is time consuming and nerve racking. After many wrong attempts, I’ve finally been able to grasp how my ideal setup should be on my OS X MBA.

Here is my notes, this is not a step-by-step guide, it’s just some concise notes which only cover the major steps, so it’s your duty to dig in further to cover your needs.


To manage my VMs I started to use Vagrant which is a fantastic tool! If your are new to Vagrant follow the "Get started" guide

For my Vagrant base box I wanted to build upon the most recent available LTS Ubuntu server version which at this time is the 12.04 Precise Pangolin. But unfortunately there wasn’t any trustworthy box available on vagrantbox.es.

However I found a very nice script which worked like a breeze and helped me builds an ubuntu-precise-64 box with a matter of a few commands. Many thanks to the authors for helping me avoiding an headache.

Build an Ubuntu Precise Vagrant box

Before starting, be sure to not have the “VirtualBox Guest Additions" image already mounted in a vm guest. I experienced an issue when the script failed to mount the image because it was already in use. I recommend to close VirtualBox and every guests before going further this should prevent any problem.

First steps:

$ git clone git://github.com/cal/vagrant-ubuntu-precise-64.git
$ cd vagrant-ubuntu-precise-64
$ ./build.sh

The build.sh script will download the precise-64 alternate iso, create a new vm, install ubuntu, build and package the vagrant box so that can take a few minutes.

When it’s done you should have a package.box file in the root directory.

Add this new box to your vagrant boxes library:

$ vagrant box add ubuntu-precise-64 /path/to/package.box

Run this command to list your available boxes, ubuntu-precise-64 should be listed:

$ vagrant box list 

Remove the git working directory you wont need it anymore:

$ sudo rm -r vagrant-ubuntu-precise-64

Init a Vagrantfile and run the VM:

$ mkdir test-ubuntu-precise-64
$ cd test-ubuntu-precise-64
$ vagrant init ubuntu-precise-64
$ vagrant up

Vagrant up deploy the vm (on first call) and run it.

Ubuntu precise can now be reached with ssh:

$ vagrant ssh

That was easy. Next we will look into the provisioning and how to manage your cookbooks : Read Vagrant Provisionning, Chef solo and Librarian-chef

03 5 / 2012