Chef Solo


Chef-Solo allows you to run cookbooks with nodes without requiring access to Chef Server (Client-Server Configuration). It allows you to install, configure and manage packages within your nodes easily.

Getting started with Chef-Solo

Install Chef

curl -L | bash

Project Setup

Create New Project Structure for Chef-Solo

  • knife solo init <Directory>

|-- chefignore
|-- cookbooks
|   |-- apache2
|   |-- myapp
|   `--
|-- data_bags
|   `--
|-- environments
|   `--
|-- roles
|   `--
|-- solo.rb
`-- web.json

Create a knife.rb for the Solo Project under .chef

/home/vagrant/chef/chef-repo/.chef$ cat knife.rb
cookbook_path [ '/home/vagrant/chef/chef-repo/cookbooks' ]

Create Your CookBook

knife cookbook create myapp

Download / Install Dependent cookbooks

Downloads a Tar Ball

knife cookbook site download apache2

Installs via Git

knife cookbook site install nodejs

Update Cookbook

  • Update metadata.rb to add dependency

vagrant@precise64:~/chef/chef-repo/cookbooks/myapp$ cat metadata.rb

depends "apache2"
  • Add apache2 receipe to myapp

vagrant@precise64:~/chef/chef-repo/cookbooks/myapp/recipes$ cat default.rb

include_recipe "apache2"

apache_site "default" do
  enable true
  • Update Attributes

vagrant@precise64:~/chef/chef-repo/cookbooks/myapp/attributes$ cat default.rb

default['apache']['default_site_enabled'] = true

Create Chef-Solo Configuration File

vagrant@precise64:~/chef/chef-repo$ cat solo.rb

file_cache_path "/root/chef-solo"
cookbook_path "/home/vagrant/chef/chef-repo/cookbooks"

Create Chef-Solo Attribute File

vagrant@precise64:~/chef/chef-repo$ cat web.json

  "run_list": [ "recipe[myapp]" ]

Installs Chef on Target Host

knife solo prepare <User>@<Host>
knife solo prepare vagrant@

Uploads cookbook to Target Host

knife solo cook vagrant@

Code available on