-- Rajesh Hegde
Intern @Justeat
 Introduction to our New Cook
 Chef Basics
 Write cookbook
 Live Demo
#Includes
 Infrastructure as a Code.
 An API for the Infrastructure.
 Continuous Delivery [ Build.. Test.. Deploy.. ].
 Chef uses Ruby as DSL.
 Open Source.
What is chef ..?
Automation In Action
 Idempotent
 Thick Clients, Thin Server
 Order Matters
Chef Principles
 Chef server
 Opscode Hosted chef server
 Private Chef
 Open source chef server
 Chef solo
Flavours of Chef
Chef Architecture
Chef Server Overview
Chef Run
Build
Node
Load
Cookbook
Configure
Node
Save
Node
 Knife
 Cookbooks
 Recipes
 Resources
 Roles
 Nodes
 Attributes
 Data bags
 Environments
Components
 Knife is a CLI between a local Chef
repository and the Chef Server.
 Knife runs on Workstation.
Knife
 Collection of recipes, attributes, templates etc..
 700+ Community Cookbooks are available.
Cookbooks
 knife cookbook list
 knife cookbook create COOKBOOK
 knife cookbook download COOKBOOK
 knife cookbook upload [COOKBOOKS...]
 knife cookbook delete COOKBOOK
 knife cookbook site download COOKBOOK
Cookbook Commands
 Define everything that is required to configure part
of a system.
 Added to a run-list before it can be used by Chef
 Always executed in the same order as listed in a run-
list
Recipes
 Get remote file.
 Apt packages
 Directory
 Link
 Templates
Resources
 Define certain patterns and processes to achieve the
goal.
 Collection of run_list and attributes
Roles
 A node is any Machine that need to be configured.
 Node Can be :
 Physical
 Virtual
 Cloud Based
Node
 Define Variables for chef run.
 Attributes can be overridden according to
precedence.
Attributes
 A data bag is a global variable that is stored as JSON
data.
 Accessible from a Chef Server.
 Stores encrypted data.
Data bags
 An environment is a way to map an
organization’s real-life workflow to
configuration.
 At least one environment : _default
 Multiple Environments like: testing, staging,
development, production.
Environments
 Run this command
 curl -L https://www.opscode.com/chef/install.sh | sudo
bash
 Git clone git://github.com/opscode/chef-repo.git
 mkdir .chef ; cd .chef
 echo "cookbook_path [ ‘path/to/cookbooks' ]" >
.chef/knife.rb
Install Chef
 Run Command:
 Knife cookbook create Justeat
That’s it… Your first cookbook is ready…..
First Cookbook
Cookbook Structure
In metadata.rb:
depends "apache2", ">= 0.99.4"
depends "mysql", ">= 1.0.5"
Cookbook Dependencies
 attributes/default.rb
node.default[“justeat”][“first_dir”] = “/etc/justeat”
First Attribute file
In recipes/default.rb
directory node[“justeat”][“first_dir”] do
user “root”
recursive true
end
Template “my.cnf” do
source “my.cnf.erb”
variables( :my_port => “3308” )
end
First Recipe
knife bootstrap 10.1.1.110 -r 'recipe[apt]' –x username –P
password –sudo
It will install chef client in node and run the recipes
specified in run list.
Bootstrap new Node
In solo.rb:
file_cache_path "/vagrant/chef-solo“
cookbook_path "/vagrant/chef-repo/cookbooks“
Run With chef-solo
In justeat.json :
{
“run_list” : [“recipe[justeat]”]
}
Run With chef-solo
 Now run :
chef-solo –c solo.rb –j justeat.json
 chef will do the needful.
Run With chef-solo
Time to go Live..
Queries..?
Thank You

Cook Infrastructure with chef -- Justeat.IN

Editor's Notes

  • #4 Chef is an infrastructure automation and configuration management framework : Infrastructure as a Code