cooking with chef

Post on 07-May-2015

1.941 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

If you’re tired of running the same commands over and over when setting up your servers, you’ll love Chef. It’s a systems integration framework that allows you to use a Ruby DSL to manage your system configurations, and then easily deploy them across your entire infrastructure, à la Capistrano. Tyler will be breaking down the various components of Chef, and showing some example configurations to get you cooking.

TRANSCRIPT

In the KitchenCooking with Chef

Tyler Hunt@tylerhunt

homegrown apps

Tweeter Phonelisten to your tweets

Problem

SystemAdministration

ConfigurationManagement

External DSLvs.

Internal DSL

SSLvs.

OpenID

XML-RPCvs.

RESTful

Test::Unit + RSpec + Mochavs.

RSpec

Puppet Chef

Lines of Code

http://www.ohloh.net/p/compare?project_0=puppet&project_1=opscode-chef

gem install chef

Opscode

“Chef is a state based,declarative configurationmanagement engine. Youdefine recipes of how youwant your system to lookand then chef makes it so.”

— Ezra Zygmuntowicz

OHAI

gem install ohai

./bin/ohai

{ "kernel": { "machine": "x86_64", "name": "Linux", "os": "GNU\/Linux", "version": "#1 SMP Wed Aug 20 21:08:51 UTC 2008", "release": "2.6.24-19-xen" }, "uptime_seconds": 12043422, "platform_version": "8.04", "platform": "ubuntu", "virtualization": { "role": "guest", "emulator": "xen" }, "os": "linux", "idletime": "115 days 23 hours 34 minutes 06 seconds", "idletime_seconds": 10020846, "lsb": { "id": "Ubuntu", "description": "\"Ubuntu 8.04.1\"", "codename": "hardy", "release": "8.04" }, "os_version": "2.6.24-19-xen"}

Nodes

Cookbooks

Recipes

Definitionsdef•i•ni•tions

(děf'ə-nĭsh'ənz) n. pl.

Attributes

Libraries

Files

TemplatesTemplatesTemplatesTemplatesTemplatesTemplatesTemplatesTemplates

cookbooks/ my_cookbook/ attributes/ definitions/ files/ libraries/ recipes/ templates/

gems Mash.new unless attribute?("gems")

gems[:rake] ||= { :version => "0.8.3"}

gems[:nokogiri] ||= { :version => "1.0.5" :source => "http://gems.github.com/"}

{ "gems": { "rake": { "version": "0.8.3" }, "nokogiri": { "version": "1.0.5", "source": "http://gems.github.com" } }}

node[:gems].each do |name, gem| gem_package name do version gem[:version] if gem[:version] source gem[:source] if gem[:source] action :install endend

node[:gems].each do |name, gem| gem_package name do version gem[:version] if gem[:version] source gem[:source] if gem[:source] action :install endend

Resources

ΓΒΑ

execute

file

user

package

remote_file

script

template

cron

directory

group

link

remote_directory

route

service

http_request

Providers

node[:gems].each do |name, gem| gem_package name do version gem[:version] if gem[:version] source gem[:source] if gem[:source] action :install endend

directory "/tmp/something" do owner "root" group "root" mode 0755 action :createend

file "/tmp/something" do owner "root" group "root" mode 0755 action :touchend

cron "noop" do hour "5" command "/bin/true"end

execute "slapadd" do command "slapadd < /tmp/something.ldif" creates "/var/lib/slapd/uid.bdb" action :runend

group "admin" do gid 999end

user "random" do comment "Random User" uid "1000" gid "users" home "/home/random" shell "/bin/zsh" password "$1$JJsvHslV$szsCjVEroftprNn4JHtDi."end

link "/tmp/passwd" do to "/etc/passwd" link_type :symbolicend

package "tar" do version "1.16.1-1" action :installend

# file from cookbookremote_file "/tmp/test" do source "test" mode 0644end

# file from remote sourceremote_file "/tmp/testfile" do source "http://example.com/files/test" mode 0644end

remote_directory "/tmp/remote_something" do source "something" files_backup 10 files_owner "root" files_group "root" files_mode 0644 owner "nobody" group "nobody" mode 0755end

route "20.0.0.0" do gateway "10.0.0.20" metric 5 route_type :net netmask "255.255.0.0"end

script "install_something" do interpreter "bash" user "root" cwd "/tmp" code <<-EOH wget http://example.com/tarball.tar.gz tar -zxf tarball.tar.gz cd tarball ./configure make make install EOHend

service "example_service" do case node[:platform] when "CentOS", "RedHat", "Fedora" service_name "redhat_name" else service_name "other_name" end supports :restart => true action [ :enable, :start ]end

template "/etc/config.conf" do source "config.conf.erb" variables({ :timeout => 360 })end

http_request "posting data" do url "http://example.com/check_in" message :some => "data"end

http://flickr.com/photos/philipyk/160559925/

http://flickr.com/photos/florin_mogos/2523984446/

http://flickr.com/photos/giorgiocardellini/271092412/

http://flickr.com/photos/onkel_wart/2487637968/

http://flickr.com/photos/dunechaser/161509118/

http://radlab.cs.berkeley.edu/wiki/Chef

http://junglist.gen.nz/chef-vs-puppet/

http://wiki.opscode.com/display/chef/Home

http://brainspl.at/articles/2009/01/15/

http://brainspl.at/articles/2009/01/31/

Thank You

top related