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.
21. “Chef is a state based,
declarative configuration
management engine.You
define recipes of how you
want your system to look
and then chef makes it so.”
— Ezra Zygmuntowicz
38. node[:gems].each do |name, gem|
gem_package name do
version gem[:version] if gem[:version]
source gem[:source] if gem[:source]
action :install
end
end
39. node[:gems].each do |name, gem|
gem_package name do
version gem[:version] if gem[:version]
source gem[:source] if gem[:source]
action :install
end
end
43. node[:gems].each do |name, gem|
gem_package name do
version gem[:version] if gem[:version]
source gem[:source] if gem[:source]
action :install
end
end
49. user quot;randomquot; do
comment quot;Random Userquot;
uid quot;1000quot;
gid quot;usersquot;
home quot;/home/randomquot;
shell quot;/bin/zshquot;
password quot;$1$JJsvHslV$szsCjVEroftprNn4JHtDi.quot;
end
52. # file from cookbook
remote_file quot;/tmp/testquot; do
source quot;testquot;
mode 0644
end
# file from remote source
remote_file quot;/tmp/testfilequot; do
source quot;http://example.com/files/testquot;
mode 0644
end
53. remote_directory quot;/tmp/remote_somethingquot; do
source quot;somethingquot;
files_backup 10
files_owner quot;rootquot;
files_group quot;rootquot;
files_mode 0644
owner quot;nobodyquot;
group quot;nobodyquot;
mode 0755
end
54. route quot;20.0.0.0quot; do
gateway quot;10.0.0.20quot;
metric 5
route_type :net
netmask quot;255.255.0.0quot;
end
55. script quot;install_somethingquot; do
interpreter quot;bashquot;
user quot;rootquot;
cwd quot;/tmpquot;
code <<-EOH
wget http://example.com/tarball.tar.gz
tar -zxf tarball.tar.gz
cd tarball
./configure
make
make install
EOH
end
56. service quot;example_servicequot; do
case node[:platform]
when quot;CentOSquot;, quot;RedHatquot;, quot;Fedoraquot;
service_name quot;redhat_namequot;
else
service_name quot;other_namequot;
end
supports :restart => true
action [ :enable, :start ]
end