What is DevOps?
What is DevOps NOT?
Friday 16 March 12
Slide 14
Slide 14 text
What is DevOps?
What is DevOps NOT?
They are making a play for our jobs
Friday 16 March 12
Slide 15
Slide 15 text
What is DevOps?
What is DevOps NOT?
They are making a play for our jobs
Devs want root
Friday 16 March 12
Slide 16
Slide 16 text
What is DevOps?
What is DevOps NOT?
DevOps is not a job title, it’s a philosophy
They are making a play for our jobs
Devs want root
Friday 16 March 12
Slide 17
Slide 17 text
What is DevOps?
What is DevOps NOT?
DevOps is not a job title, it’s a philosophy
They are making a play for our jobs
Devs want root
So many words
Friday 16 March 12
Slide 18
Slide 18 text
DevOps, for me
Friday 16 March 12
Slide 19
Slide 19 text
DevOps, for me:
Testing
Friday 16 March 12
Slide 20
Slide 20 text
DevOps, for me:
Testing
Monitoring
Friday 16 March 12
Slide 21
Slide 21 text
DevOps, for me:
Testing
Automation
Monitoring
Friday 16 March 12
Slide 22
Slide 22 text
DevOps, for me:
Testing
Automation
Monitoring
Friday 16 March 12
Slide 23
Slide 23 text
DevOps, for me:
Testing
Automation
Monitoring
Don’t release broken things
Know when things break
Replace/fix broken things instantly
Friday 16 March 12
Slide 24
Slide 24 text
✔ ?
Friday 16 March 12
Slide 25
Slide 25 text
SCCS:
Source Code Control System
Friday 16 March 12
Slide 26
Slide 26 text
SCCS:
Source Code Control System
1972
40 Years Ago!
Friday 16 March 12
Slide 27
Slide 27 text
Revision Control
✔
Friday 16 March 12
Slide 28
Slide 28 text
Revision Control
Test Driven Development
✔
Friday 16 March 12
Slide 29
Slide 29 text
Revision Control
Test Driven Development
Feature Branches
✔
Friday 16 March 12
Slide 30
Slide 30 text
Revision Control
Test Driven Development
Continuous Integration
Feature Branches
✔
Friday 16 March 12
Slide 31
Slide 31 text
Revision Control
Test Driven Development
Continuous Integration
Feature Branches
Staging Environments
✔
Friday 16 March 12
Slide 32
Slide 32 text
Revision Control
Test Driven Development
Continuous Integration
Feature Branches
Staging Environments
AGILE
✔
Friday 16 March 12
Instant Feedback
Rollbacks
Confidence
No fear of change
Friday 16 March 12
Slide 37
Slide 37 text
Code Infrastructure
Friday 16 March 12
Slide 38
Slide 38 text
Code
Infrastructure
Friday 16 March 12
Slide 39
Slide 39 text
Code
Infrastructure As
Friday 16 March 12
Slide 40
Slide 40 text
$ ssh root@web1
Last login: Tue Mar 13
# apt-‐get install apache2
...
# vim /etc/apache2/sites-‐enabled/default.conf
...
# /etc/init.d/apache2 restart
...
# scp web2:/root/.ssh/authorized_keys ~/.ssh
Friday 16 March 12
Slide 41
Slide 41 text
Chef
Friday 16 March 12
Slide 42
Slide 42 text
chef-client on node
retrieves
configuration
from server
use knife to push
config to server
use knife to query and
ssh to clients
SERVER
CLIENT
(workstation)
CLIENT
(server/node)
Friday 16 March 12
Chef/nodes/web1.json
Chef/roles/web.rb
Friday 16 March 12
Slide 47
Slide 47 text
run_list("recipe[apache]",
"role[monitoring]")
Friday 16 March 12
Slide 48
Slide 48 text
run_list("recipe[apache]",
"role[monitoring]")
Friday 16 March 12
Slide 49
Slide 49 text
Chef/nodes/web1.json
Chef/roles/web.rb
Chef/cookbooks/apache/
recipes/default.rb
Friday 16 March 12
Slide 50
Slide 50 text
package "apache2" do
action :install
end
Friday 16 March 12
Slide 51
Slide 51 text
apache_modules = ['wsgi', 'ssl',
'auth_tkt', 'proxy_http',
'headers', 'rewrite', 'status']
apache_modules.each do |mod|
apache_module mod do
enable true
notifies :restart,
"service[apache2]"
end
end
Friday 16 March 12
Slide 52
Slide 52 text
apache_modules = ['wsgi', 'ssl',
'auth_tkt', 'proxy_http',
'headers', 'rewrite', 'status']
apache_modules.each do |mod|
apache_module mod do
enable true
notifies :restart,
"service[apache2]"
end
end
Friday 16 March 12
Slide 53
Slide 53 text
package "apache2" do
case node[:platform]
when "centos","redhat","fedora","suse"
package_name "httpd"
when "debian","ubuntu"
package_name "apache2-mpm-prefork"
end
action :install
end
Friday 16 March 12
Slide 54
Slide 54 text
package "apache2" do
case node[:platform]
when "centos","redhat","fedora","suse"
package_name "httpd"
when "debian","ubuntu"
package_name "apache2-mpm-prefork"
end
action :install
end
Friday 16 March 12
Slide 55
Slide 55 text
Chef/nodes/web1.json
Chef/roles/web.rb
Chef/cookbooks/apache/
recipes/default.rb
attributes/default.rb
Friday 16 March 12
Slide 56
Slide 56 text
default[:apache][:version] = "2.2"
Friday 16 March 12
Slide 57
Slide 57 text
package "apache2" do
action :install
version "#{node[:apache][:version]}"
end
Friday 16 March 12
Slide 58
Slide 58 text
Chef/nodes/web1.json
Chef/roles/web.rb
Chef/cookbooks/apache/
recipes/default.rb
attributes/default.rb
templates/default/apache2.conf.erb
Friday 16 March 12
Slide 59
Slide 59 text
template "#{node[:apache][:dir]}/apache2.conf" do
source "apache2.conf.erb"
owner "root"
mode 0644
notifies :restart, resources(:service =>
"apache2")
end
Friday 16 March 12
Slide 60
Slide 60 text
It’s all Ruby
Friday 16 March 12
Slide 61
Slide 61 text
It’s all Ruby
http://wiki.opscode.com/display/chef/Just+Enough+Ruby+for+Chef
“Just Enough Ruby for Chef”
Friday 16 March 12
class Chef
class Recipe
def apache_ports(&block)
@node[:apache][:vhosts].each do |vh|
vh[:ports].each do |p|
block.call(p)
end
end
end
end
end
Friday 16 March 12
Slide 65
Slide 65 text
apache_ports do |p|
firewall_port p do
action :open
end
end
Friday 16 March 12
Slide 66
Slide 66 text
apache_ports do |p|
firewall_port p do
action :open
end
end
Friday 16 March 12
Slide 67
Slide 67 text
define :firewall_port, :action => :open do
if not params.has_key?(:port)
params[:port] = params[:name]
end
if params[:action] == :open
execute "open #{params[:port]}" do
command "iptables -A INPUT --destination-port
#{params[:port]} -j ACCEPT"
end
else
execute "close #{params[:port]}" do
command "iptables -A INPUT --destination-port
#{params[:port]} -j DROP"
end
end
end
Friday 16 March 12
Slide 68
Slide 68 text
Providers
package "apache2" do
action :install
end
node[:platform]
apt-get install
brew install
yum install
Friday 16 March 12
Slide 69
Slide 69 text
"#{File.expand_path(
Chef::Config[:file_cache_path]
)}/handlers/yola.rb"
Friday 16 March 12
Slide 70
Slide 70 text
"#{File.expand_path(
Chef::Config[:file_cache_path]
)}/handlers/yola.rb"
class YolaHandler < Chef::Handler
def report()
run_status.updated_resources.each do |r|
campfire_speak(r.to_s)
end
end
end
Friday 16 March 12
Slide 71
Slide 71 text
"#{File.expand_path(
Chef::Config[:file_cache_path]
)}/handlers/yola.rb"
class YolaHandler < Chef::Handler
def report()
run_status.updated_resources.each do |r|
campfire_speak(r.to_s)
end
end
end
Friday 16 March 12
Integration
configuration data vs configuration logic
Friday 16 March 12
Slide 81
Slide 81 text
Integration
configuration
data vs configuration logic
Friday 16 March 12
Slide 82
Slide 82 text
Integration
vs configuration logic
Ohai Collects infrastructure data
Stored and indexed in NoSQL
Search and use
configuration
data
Friday 16 March 12
Slide 83
Slide 83 text
Attributes
default
normal
override
automatic
(A side note on)
Friday 16 March 12
Slide 84
Slide 84 text
Attributes
default
normal
override
automatic
cookbooks, data bags
node definitions
for special cases
ohai
(A side note on)
Friday 16 March 12
Slide 85
Slide 85 text
Integration
search(:node, 'role:webbackend') do |wb|
haproxy_backend "#{wb[:apache][:port]}" do
action :create
end
end
Systems auto-discover each other
Configuration is responsive to changes
(Back to)
Friday 16 March 12
Slide 86
Slide 86 text
Integration
search(:node, 'role:webbackend') do |wb|
haproxy_backend "#{wb[:apache][:port]}" do
action :create
end
end
Systems auto-discover each other
Configuration is responsive to changes
So you don’t have to be!
Friday 16 March 12
Slide 87
Slide 87 text
Jonathan Hitchcock
@vhata
github.com/vhata
Friday 16 March 12