machines rather than view an entire infrastructure as a combined whole" “A good infrastructure, whether departmental, divisional, or enterprise-wide, is a single loosely- coupled virtual machine, with hundreds or thousands of hard drives and CPU's.” -- Bootstrapping an Infrastructure USENIX LISA ’98 http://www.infrastructures.org/papers/bootstrap/bootstrap.html
like any other code base • Reconstruct operations from code repository, data backup, and bare metal resources. http://www.flickr.com/photos/louisb/4555295187/
; do scp ntp.conf root@$i:/etc/ ntpd.conf ; done for i in `cat servers.txt` ; do ssh root@$i /etc/init.d/ntpd restart ; done for i in `cat servers.txt` ; do ssh root@$i chkconfig ntpd on ; done • ^ does not scale http://www.flickr.com/photos/alexerde/3479006495
of declarative interface • Eliminates brittleness of scripting • Identity function: f(x)=x package "ntp" do action :install end Idempotence service "ntpd" do action [:enable,:start] end cookbook_file "/etc/ntp.conf" do source "ntp.conf" owner "root" group "root" mode 0644 action :create notifies :restart, “service[ntpd]” end
"ntpd" do action [:enable,:start] end cookbook_file "/etc/ntp.conf" do source "ntp.conf" owner "root" group "root" mode 0644 action :create notifies :restart, “service[ntpd]” end while true do end • You’ll hear this a lot • Property of declarative interface • Eliminates brittleness of scripting • Identity function: f(x)=x • Safe to repeat
end service "ntpd" do action [:enable,:start] ignore_failure true end cookbook_file "/etc/ntp.conf" do source "ntp.conf" owner "root" group "root" mode 0644 action :create notifies :restart, “service[ntpd]” ignore_failure true end • Agents “converge” a system to desired state • Repetition inches closer to desired state • It eventually gets there • SCIENCE!
• Clients are API users • Public keys on server • Private keys local to machines chef-client chef-client chef-client chef-client Knife Knife someara.pem jtimberman.pem node5.fqdn.pem someara.pub jtimberman.pub node5.fqdn.pub
"haproxy-default.erb" owner "root" group "root" mode 0644 notifies :restart, "service[haproxy]" end service "haproxy" do action [:enable, :start] end • Recipes contain lists of resources Recipes
do version "2.2.11-2ubuntu2.6" action :install end template "/etc/apache2/apache2.conf" do source "apache2.conf.erb" owner "root" group "root" mode 0644 action :create end Resources
parameters package "apache2" do version "2.2.11-2ubuntu2.6" action :install end template "/etc/apache2/apache2.conf" do source "apache2.conf.erb" owner "root" group "root" mode 0644 action :create end Resources
parameters • Take action to put the resource in the declared state package "apache2" do version "2.2.11-2ubuntu2.6" action :install end template "/etc/apache2/apache2.conf" do source "apache2.conf.erb" owner "root" group "root" mode 0644 action :create end Resources
Solr • Can search through the API • From knife and in recipes • Returns an array of JSON Node objects http://www.flickr.com/photos/fotos_medem/3399096196/