reconstruction of the business from nothing but a source code repository, an application data backup, and bare metal resources “ - Jesse Robbins, Opscode Tuesday, November 20, 12
like, not how. Chef is Idempotent: Running recipes again should converge system back without failing. Chef is Convergent: Any changes will be returned to the state defined in Chef. Tuesday, November 20, 12
Packages can be installed via apt or yum but the package resource abstracts this. Providers: Providers allow Chef to support multiple platforms with a single Resource. package “tar” do action :install end Debian, Ubuntu: Chef::Provider::Package::Apt Redhat, Centos: Chef::Provider::Package::Yum Tuesday, November 20, 12
are four types of attributes in order of precedence (highest to lowest): - automatic - override - normal - default Attributes can be set on: - cookbooks - environments - roles - nodes Tuesday, November 20, 12
- Applied to nodes - Define a run list and role attributes role/web_server run_list: recipe[apache2], recipe[rails] attributes: “apache2” => { “port” => 8080” } Tuesday, November 20, 12
globally accessible data Environments: - Provide a way to manage different environments (production, staging, dev) - Lock cookbook versions by environment - Can specify run lists and attributes environment/production name “production” run_list: role[base] cookbook_version({ “my_rails_app” => “=1.2.0” }) attributes: “rails” => { “port” => “4000” } Tuesday, November 20, 12
Server that allows you to query information about your infrastructure. - Chef indexes: Roles, Nodes, API Clients and Environments Search Examples: - knife search admins ‘username:root’ - knife search node ‘name:app*’ - knife search node role:web_server - knife search node “role:database AND chef_environment:production” knife ssh ‘role:web_server AND chef_environment:production’ uptime Tuesday, November 20, 12
chef resources. - Use role attributes to override cookbooks. - Use environments to lock cookbook versions. - Create cookbooks that inherit from community cookbooks. - Store any static data in data bags. - Not just for servers. Deploying workstations should be easy. Tuesday, November 20, 12