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

A Chef Repository Designed to Demonstrate the Power of Chef, Librarian and Vagrant

Prerequisites

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

Download the chef-repo

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

Setup Librarian

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

Vagrant

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 but disable the first chef run.

The first chef-solo run will fail because the preinstalled version of chef in the vm isn't high enough for chef-solo-search cookbook.

vagrant up --no-provision

Update Chef gem in the vm.

'vagrant ssh' lets you easily log into the vm but here we will just send the vm a command to update chef so chef-solo-search cookbook will work enabling data bag search within a chef-solo run.

vagrant ssh -c 'sudo gem update chef --no-ri --no-rdoc'

Run chef-solo in the vm.

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 provision

You should see the vm's web server.

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
Clone this wiki locally