Skip to content
jeremiahsnapp edited this page Apr 20, 2012 · 25 revisions

Demonstrating the Power of Chef, Librarian and Vagrant

Opscode Chef provides configuration management to your infrastructure.

Prerequisites

Make sure you have all the prerequisites to be productive with this Chef repository.

They are easy to uninstall later.

Download the chef-repo

cd ~
mkdir -p chef/cookbooks
cd chef
git clone git://github.com/jeremiahsnapp/chef-repo.git

Setup Librarian - (Bundler for your Chef Cookbooks)

How This Chef Repo Manages Cookbooks
This chef-repo has a ready-to-use Librarian Cheffile.

cd chef-repo
librarian-chef clean
librarian-chef install

(Optional) Create Encrypted Data Bag Key

Uncomment the chef.encrypted_data_bag_secret_key_path line in Vagrantfile.

mkdir ~/.chef
openssl rand -base64 512 | tr -d '\r\n' > ~/.chef/chef_data_bag_key

Chef-Solo-Search

This chef-repo has chef-solo-search cookbook which enables data bag search within a chef-solo run.
This requires the VM to have Chef >= 0.10.4.

Vagrant - (Easily Manages VirtualBox VM's)

This chef-repo has a ready-to-use Vagrantfile. The Vagrantfile will automatically download the appropriate vagrant box when 'vagrant up' is run.

The Vagrantfile is configured to apply the chef-repo/roles/test_chef_solo.rb role run_list which is configured to apply the 'role[web]' which will install and configure many things including:

Power on the Vagrant VM and let chef-solo run.

This will take a while but you should see green colored chef output scroll by in your terminal. If you ever see any red colored output then the chef run had some errors.

vagrant up

You should see the vm's web server.

Log into the vm if you want to.

vagrant ssh

Make your own changes to the chef-repo.

If you change any cookbooks make sure librarian pulls the changes into chef-repo/cookbooks.

librarian-chef clean
librarian-chef install

You could have also just run 'librarian-chef install' to only pull changes instead of starting with a clean slate The choice is yours but sometimes it's nice to be sure everything is up to date from a clean slate

Rerun chef-solo.

vagrant provision

Power off vm.

vagrant halt

Destroy vm.

vagrant destroy