View
12
Download
0
Category
Preview:
Citation preview
Intro to Chef & Chef Delivery
Agenda
• Overview
• Chef Software Platform
• Building Blocks
• Automation Patterns
• Chef Delivery!
Nathen Harvey
• Community Director at Chef
• Co-organizer of DevOpsDC Meetup
• Co-organizer of DevOpsDaysDC … but you missed it
• Loves farms and eggs • http://ei.chef.io • http://eggs.chef.io
Overview
• Chef is an automation framework that enables Infrastructure as Code
• Chef leverages reusable definitions to automate desired state
• Chef is API driven
• Chef supports Linux variants, Unix variants, AIX and Windows, all as first class citizens.
The Chef Software Platform
Chef Analytics Chef Delivery Management console
High availability and replication
Chef Provisioning
Chef Development Kit
Cookbook and policy authoring
Test-driven infrastructure
Containers
Cloud
VMs
Devices
Chef Server Chef Solo
Eco
syst
em
(con
tent
, plu
gins
, etc
.)
Building Blocks
Building Blocks: What is a Resource?
• A Resource is a system state you define • Example: Package installed, state of a service, configuration file existing
• You declare what the state of the resource is • Chef automatically determine HOW that state is achieved
package "httpd" do action :install end
windows_feature "IIS-WebServerRole" do action :install end
Building Blocks: What is a Recipe?
• A recipe is a collection of Resources • Resources are executed in the order they are listed
On Linux based OSes:
package "httpd" do action :install end template ”/var/www/index.html" do source ”index.html.erb” mode "0644" end service "httpd" do action [ :enable, :start ] end
windows_feature "IIS-WebServerRole" do action :install end template 'c:\inetpub\wwwroot\Default.htm' do source "Default.htm.erb" rights :read, "Everyone" end service "w3svc" do action [ :enable, :start ] end
Building Blocks: What is a Cookbook?
• A cookbook is a set of recipes • A cookbook is a defined set of items
and different outcomes that you expect to address • A cookbook could have a recipe to install
apache2/httpd but also another set of recipes to activate modules required.
./attributes
./attributes/default.rb
./CHANGELOG.md
./metadata.rb
./README.md
./recipes
./recipes/application.rb
./recipes/balancer.rb
./recipes/database.rb
./recipes/default.rb
./recipes/webserver.rb
./templates
./templates/default
./templates/default/mysite.conf.erb
Building Blocks
Building Blocks
Automation Patterns
CHEF DELIVERY
VALIDATED IN OUR ENGAGEMENTS WITHENTERPRISE AND BIG WEB CUSTOMERS.
WE'VE IDENTIFIED A PROVEN PIPELINE
U-071982-C
STABLE PIPELINESteps
Create a new change1!
Test ChangeLocally2!
Verification Tests
SubmitChange3!
ReviewChange4!
Build Artifacts
Acceptance Tests
ApproveChange5!
Release Process
DeliverChange6!
manual automated
U-071982-C
A SHARED PIPELINEACROSS PROJECTS AND TEAMS !
COMMON PIPELINEOne Pipeline
Delivery Pipeline - Shared
union! rehearsal! delivered!
Acceptance Pipelines - Private
review approve deliverChange
Cookbook [A]
review approve deliverChange
Cookbook [B]
review approve deliverChange
Application [A]
review approve deliverChange
Application [B]
U-071982-C
Infrastructure & Applications
THE STAGES ARE FIXED
EACH STAGE HAS A FIXED SET OF PHASES
A UNIFIED PIPELINE SHAPE
COMMON PIPELINESteps
manual automated
VerifyLint
Syntax
Unit
BuildMerge
Lint
Syntax
Unit
Quality
Security
Publish
Provision
Deploy
Smoke
Functional
Compliance
Acceptance UnionProvision
Deploy
Smoke
Functional
Compliance
RehearsalProvision
Deploy
Smoke
Functional
Compliance
DeliveredProvision
Deploy
Smoke
Functional
Compliance
Stages
customizable
Verify Build
Acceptance
Union
Rehearsal
Delivered
SubmitChange3!
ReviewChange4!
ApproveChange5!
DeliverChange6!
Chef Delivery
Create a new change1!
Test ChangeLocally2!
Workstation
U-071982-C
BUILD COOKBOOK
!"" recipes !"" default.rb
!"" lint.rb !"" syntax.rb !"" unit.rb !"" quality.rb !"" security.rb !"" publish.rb !"" provision.rb
!"" deploy.rb !"" smoke.rb
$"" functional.rb
U-071982-C
PHASE EXECUTION
log "Running unit"
repo = node['delivery_builder']['repo']
execute “run my junit tests" do command "mvn test" cwd repoend
U-071982-C
COOKBOOK WORKFLOW
U-071982-C
Supermarket !
Chef Server!
review! approve ! deliver!Change !
Cookbook !
Node! Node! Node!
Node! Node! Node!
Node! Node! Node!
Publi
sh!
Publish!
Update !
APPLICATION WORKFLOW
U-071982-C
review! approve ! deliver!Change !
Application!
Node! Node! Node!
Node! Node! Node!
Node! Node! Node!
Deploy!
1 2 3
2 2 3
3 3 3
EASILY CREATE DELIVERY PIPELINES
PROJECT GIT REPOBUILD COOKBOOK
PROJECT CONFIG FILE
U-071982-C
CONFIG.JSON
{ "version": "1", "build_cookbook": "./.delivery/build_cookbook", "build_nodes": { "default": [“name:*buildnode-*”],
"unit": [“name:*-unittest*”], "lint": [“name:*-linttest*”],
"build": [“name:*-builder*”] }}
U-071982-C
HOW IT WORKSCLI
WebBrowser
Job Dispatch
Push
Chef Server
erlang
Delivery
erlang
pgSQL
DB
git
SCM
0101!1010!
Build NodeBuild NodeBuild Nodes
U-071982-C
U-071982-C
Recommended