Learn how to automate your infrastructure to make more time for fun things. In this rapid fire intro to Chef, an open source provisioning and automation platform, we'll touch on the strengths of it's flexible architecture as well as showing some concrete and simple starting points on your path to become an executive chef.
Under The Covers - Chef in 20 Minutes www.opscode.com
Congratulations!!! • You have a Cloud • Now what? http://www.ﬂickr.com/photos/ian_munroe/4758240536/
APIs are awesome • You can provision compute resources in seconds • You can provision storage resources in seconds • That’s cool. http://www.ﬂickr.com/photos/jdhancock/3634246981/Give me some operating system and put it on the network
Chef can help with that• knife ec2 server • knife brightbox create server create• knife rackspace • knife vsphere server create server create• knife terremark • knife openstack server create server create• knife gandi • knife eucalyptus server create server create• knife bluebox server createhttp://www.ﬂickr.com/photos/kyz/3122499444/
But then what?http://www.ﬂickr.com/photos/doctorow/2698336843
You need to conﬁgure themGive me some operating system and put it on the network
Chef can help with that too • That’s what we do.
Golden Images are not the answer• Gold is heavy• Hard to transport• Hard to mold• Easy to lose configuration detailhttp://www.ﬂickr.com/photos/bankofengland/5762003476
Chef is Infrastructure as Code • Programmatically provision and configure • Treat like any other code base • Reconstruct operations from code repository, data backup, and bare metal resources. http://www.ﬂickr.com/photos/louisb/4555295187/
With declarative interfaces • Define policy • Say what, not how • Pull not Push http://www.ﬂickr.com/photos/bixentro/2591838509/
That looks like thispackage "ntp" do action :installend template "/etc/ntp.conf" do source "ntp.conf.erb" owner "root" group "root" mode 0644 action :create variables( :ntp_server => “time.example.com”) notifies :restart, “service[ntpd]” end service "ntpd" do action [:enable,:start] end
That looks like thispackage "net-snmp" do action :installend template "/etc/snmpd.conf" do source "snmpd.conf.erb" owner "root" group "root" mode 0644 action :create variables( :community_string => “not_public”) notifies :restart, “service[snmpd]” end service "snmpd" do action [:enable,:start] end
Creating recipes and cookbooks• Recipes are collections of Resources• Cookbooks contain recipes, Templates, files, custom resources, etc• Code re-use and modularity http://www.flickr.com/photos/shutterhacks/4474421855/
Apply Run Lists to Nodes Server Server chef-server Server Server Ohai! API chef-client Give me recipe[ntp::client] ntp node client.rbexecuted in order!
Build up reusable code Server Server chef-server Server Server Ohai! chef-client API Give me “ntp::client”, ntp “openssh::server” openssh node client.rb server.rbexecuted in order!
Apply them in order Server Server chef-server Server Server Ohai! chef-client Give me API “recipe[ntp::client]”, ntp “recipe[openssh::server]”, “recipe[apache]”, openssh node “recipe[php]” client.rb apache server.rb php default.rb default.rbexecuted in order!
Roles Server Server chef-server Server Server Role Recipe API Role Role Recipe Role Recipe RecipeKnife Recipe Recipe Recipe
Roles Server Serverchef-server Server Server chef-client Ohai! API Give me ntp “role[base]”, “role[webserver]” openssh node client.rb apache server.rb php default.rb default.rb
Roles Server Serverchef-server Server Server ntp openssh chef-client API client.rb apache php server.rb “role[webserver]” default.rb ntp default.rb node openssh chef-client client.rb mysql server.rb server.rb “role[database]” node
Recipes can search chef-sever • Search for nodes with Roles • Find configuration data • IP addresses • Hostnames • FQDNs http://www.flickr.com/photos/fotos_medem/3399096196/
And stitch together Infrastructures App LBs App Servers App DB Cache App DBs
Your Infrastructure is a snow flake App LBs App Servers App DB Cache Floating IP? App DBs
And it Evolves App LBs Cache App ServersNoSQL DB Cache DB slaves DBs