Up and running chef-solo instance using Vagrant

This will describe a quick and easy way to get a chef-solo instance up and running using Vagrant. This document is intended for learning Chef and not intended for production use.

I am using Mac OS X for this tutorial. I am sure it is simiar for Windows and Linux.

Prerequisites

  • Oracle Virtual Box – Download
  • Vagrant – Download
  • Working knowledge of Vagrant

 Setting It Up

Create a directory for the Vagrantfile and bootstrap.sh. I named mine chef_solo. Change into that directory and create a Vagrantfile with the following:

Vagrant.configure("2") do |config|
  config.vm.box = "ubuntu/trusty64"
  config.vm.provision :shell, path: "bootstrap.sh"
end

This will spin up an Ubuntu server 14.04 64 bit instance and run bootstrap.sh.

Now edit bootstrap.sh and add the following:

#!/usr/bin/env bash

apt-get update
apt-get install -y curl
curl -L https://www.opscode.com/chef/install.sh | bash
chef-solo -v

Once the VM is up and running, bootstrap.sh will apply updates, install curl, download and install chef-solo using the Omnibus installer, and print out the version of Chef.

Chef-solo up and running

Now simply run vagrant up and your chef-solo instance will be installed.