Cfg mgmtcamp c-dwithchef

G
George MirandaHead Of Marketing at Buoyant, Inc
So Continuous.
Much Delivery.
Very Chef.
Wow.
A Case Study on using Chef to start building a
Continuous Delivery Pipeline
About Me

•

George Miranda

•

Sr Consultant at Chef Software, Inc.

•

Unix guy (15+ years)
Cfg mgmtcamp c-dwithchef
Cfg mgmtcamp c-dwithchef
Cfg mgmtcamp c-dwithchef
Minimum Viable Pipeline
What we know
•

Step 1: Develop a new change

•

Step 2: ???

•

Step 3: Production!

•

MOAR FASTERZ
Case Study: Requirements
•

Must utilize existing tools within the company

•

Git for SCM

•

Jenkins approved for use

•

Working in a static VM environment

•

Just migrated to single cookbook repos

•

Starting with infrastructure cookbooks

•

Want a manual go-to-production button (ugh!)
Case Study: Code Review Model
•

Git PR model: branch from master for any
new feature

•

4-person team, only 3 active at any time

•

Code review done manually and informally

•

Simple communication/reqs (makes it easy!)
Figuring out new workflow
•

How are developers expected to work locally?

•

When do they push to remote? How do we
verify their work?

•

Code Review criteria: what does it mean to be
ready to merge?

•

How do we go from merged code to artifact?

•

How do we get that artifact all the way to
Production?
Local Development Work
•

New branch for every feature

•

Create a failing test

•

Write a resource to pass the test

•

Local commits

•

Test-Kitchen + guard

•

Once local tests passed, push to remote
Push to remote
•

Open a Pull Request (new branch to master)

•

Triggers a build via Jenkins GHPRB plugin
Push to remote
The Verify Build Job
•

Verify syntax (knife cookbook check)

•

Foodcritic Rules

•

Test-Kitchen w/ BATS busser
BATS: Simple Unit Tests
@test "My directory is created" {!
test -d /foo/bar!
}!
!

@test "A basharific test" {!
if [ foo != bar ]; then!
skip "foo isn't bar"!
fi!
!

run foo!
[ "$status" -eq 0 ]!
}!
!
•
•

https://github.com/sstephenson/bats
Super low learning curve (but also very limited)
Push to remote
•

If failed, notify
•

Another commit to the same branch
triggers another Verify Build Job

•

Super easy to track, comment, and approve

•

If passed, let’s go to Human Code Review
Human Code Review Rules
•

Only one change per one cookbook at one
time

•

Must have test for feature that changed
•

One for one: resource unit tests

•

Consider the smoke test
Unit Test vs Smoke Test
•

Unit tests: small, fast, check one single
concern
•

•

Smoke tests: test multiple things in the course
of one concern
•

•

In this context: checking Chef resources

In this context: check the intent of a recipe

Note: that was testing for this use case
When are we ready to merge?
•

Only 3 active team members at any given
time
•
•

•

Submitter cannot approve
Merge approval requires 2 approvals

Code review can happen at any time, but
only merge when you’re ready to fix it.
Merged code to artifact
•

Freeze your cookbooks!

•

Semantic versioning: Major.Minor.Patch
•
•

•

You own Major.Minor
The Pipeline owns .Patch

No one gets to knife upload

No one.!
Ever.!
•

"git merge" is the new "knife upload"
Cfg mgmtcamp c-dwithchef
The Integration Job
•

Bumps Cookbook version

•

Re-commits to master

•

Upload frozen cookbook (via berks)

•

Pin that new cookbook to the Integration
environment

•

Converge all nodes that use that cookbook
The Integration Job

•

First sign that things may be broken

•

These nodes also run smoke tests
•

serverspec, minitest, etc
The Integration Job
•

We survived! Trigger the next job(s)

•

The Jenkins Build Pipelines Plugin allows
upstream/downstream definitions to string
together jobs

•

From here out, it’s all the same Promote Job*

•

After the Integration job, we just run X number
of Promote Jobs
* (mostly)
Cfg mgmtcamp c-dwithchef
Cfg mgmtcamp c-dwithchef
Cfg mgmtcamp c-dwithchef
Promote Jobs

•

Pin cookbook to new Chef Environment

•

Converge all nodes using this cookbook

•

Run Tests
Pin the cookbook to Env
#!/opt/chef/embedded/bin/ruby

!

require 'chef/environment'
require 'chef'
Chef::Config.from_file("/var/lib/jenkins/tools/knife.rb")

!

def pin_env(env, cookbook_versions)
to = Chef::Environment.load(env)
cookbook_versions.each do |cb, version|
puts "Pinning #{cb} #{version} in #{env}"
to.cookbook_versions[cb] = version
end
to.save
end

!

cookbook_data = Array.new

!

if File.exists?(File.expand_path(File.join(ENV['WORKSPACE'], 'metadata.rb')))
metadata_file = File.expand_path(File.join(ENV['WORKSPACE'], 'metadata.rb'))
File.read(metadata_file).each_line do |line|
if line =~ /^names+["'](w+)["'].*$/
cookbook_data << $1
end
if line =~ /^versions+["'](d+.d+.d+)["'].*$/
cookbook_data << "= #{$1}"
end
end
end

!

cookbook_versions = Hash[*cookbook_data]

!

pin_env(ARGV[0], cookbook_versions)
Pin the cookbook to Env

$ berks apply <environment>
Converge Nodes
$ knife ssh "recipes:mycookbook AND
chef_environment:promote-environment”
'sudo chef-client'!
… OR …
Pushy!
Run Tests
•

Most testing frameworks have a Report
Handler to automatically run tests
•

chef-serverspec-handler

•

minitest-handler

•

Deploy to your nodes by adding
‘chef_handler’ to their run_list

•

Many community cookbooks are already
packaged with tests
Run Tests
•

In this particular use case:
•

Build job: BATS (unit tests)

•

Integration & Promote jobs: serverspec
(smoke tests)

•

UAT: also ran Cucumber tests (acceptance)
Cfg mgmtcamp c-dwithchef
Promoting to more environments
•

Can string together N number of promotions
•

UAT

•

Production A

•

Production B

•

etc
Cfg mgmtcamp c-dwithchef
Cfg mgmtcamp c-dwithchef
Push to Production

•

In production monitoring is the test

•

Could not queue up changes reliably anyway

•

There is no spoon
Results
•

Small incremental deployments led to greater
confidence

•

TDD was pushed to the forefront of priorities

•

Commitment from Dev group to write
application deployment cookbooks

•

But the biggest lesson learned…
Let’s Go Devop with a CD tool
•

Continuous Delivery is a practice, not a tool

•

Small incremental changes in code

•

Small incremental changes in workflow

•

Small incremental changes in tooling

•

You will constantly improve your code, your
workflow, your tools, your team, and your
skills.
RECAP
What We Wanted
•

Step 1: Develop a new change

•

Step 2: ???

•

Step 3: Production!

•

MOAR FASTERZ
Wait… what was Step 2?
•

(Pre-req) Test Driven Development

•

2A. Establish development workflow before submitting changes *

•

2B. Auto verification of submission before humans look at it

•

2C. Humans Apply Code Review Criteria *

•

2D. Don’t merge unless you mean it *

•

2E. Merge kicks off an Integration Job

•

2F. Followed by a series of Promotion Jobs

•

2G. There is no spoon *
What We Got
•
•

Step 1: Develop a new change
Step 2:

(Pre-req) Test Driven Development
2A. Establish development workflow before submitting changes *
2B. Auto verification of submission before humans look at it

!

2C. Humans Apply Code Review Criteria *
2D. Don’t merge unless you mean it *
2E. Merge kicks off an Integration Job

!

2F. Followed by a series of Promotion Jobs
2G. There is no spoon *

•

Step 3: Production!

•

Step 4: Level Up. This is great!

•

Step 5: MOAR THINGS! Wait. This is hard!

•

Go to Step 1
Key Chef Ecosystem Tools
•

Test Kitchen — http://kitchen.ci/

•

Guard Plugin for Test Kitchen —
https://github.com/test-kitchen/guard-kitchen

•

Foodcritic — http://acrmp.github.io/foodcritic/

•

Berkshelf — http://berkshelf.com/
Helpful Jenkins Plugins
•

git

•

github

•

build-pipeline-plugin

•

ghprb

•

warnings

•

mailer
I want to hear from you!
!

@gmiranda23
gmiranda@getchef.com
1 of 46

Recommended

Introduction to Go by
Introduction to GoIntroduction to Go
Introduction to GoAmulya Sharma
514 views19 slides
Continuous delivery with open source tools by
Continuous delivery with open source toolsContinuous delivery with open source tools
Continuous delivery with open source toolsSebastian Helzle
5.4K views24 slides
Automate your Development Environment with Vagrant & Chef by
Automate your Development Environment with Vagrant & ChefAutomate your Development Environment with Vagrant & Chef
Automate your Development Environment with Vagrant & Chef Michael Lihs
1.9K views29 slides
Vagrant, Chef and TYPO3 - A Love Affair by
Vagrant, Chef and TYPO3 - A Love AffairVagrant, Chef and TYPO3 - A Love Affair
Vagrant, Chef and TYPO3 - A Love AffairMichael Lihs
1.8K views43 slides
Make It Cooler: Using Decentralized Version Control by
Make It Cooler: Using Decentralized Version ControlMake It Cooler: Using Decentralized Version Control
Make It Cooler: Using Decentralized Version Controlindiver
3.8K views45 slides
Michelin Starred Cooking with Chef by
Michelin Starred Cooking with ChefMichelin Starred Cooking with Chef
Michelin Starred Cooking with ChefJon Cowie
5.4K views180 slides

More Related Content

What's hot

Ansible top 10 - 2018 by
Ansible top 10 -  2018Ansible top 10 -  2018
Ansible top 10 - 2018Viresh Doshi
236 views34 slides
An Open-Source Chef Cookbook CI/CD Implementation Using Jenkins Pipelines by
An Open-Source Chef Cookbook CI/CD Implementation Using Jenkins PipelinesAn Open-Source Chef Cookbook CI/CD Implementation Using Jenkins Pipelines
An Open-Source Chef Cookbook CI/CD Implementation Using Jenkins PipelinesSteffen Gebert
5.3K views60 slides
Managing Jenkins with Jenkins (Jenkins User Conference Palo Alto, 2013) by
Managing Jenkins with Jenkins (Jenkins User Conference Palo Alto, 2013)Managing Jenkins with Jenkins (Jenkins User Conference Palo Alto, 2013)
Managing Jenkins with Jenkins (Jenkins User Conference Palo Alto, 2013)Gareth Bowles
6.4K views37 slides
Introduction to Git for developers by
Introduction to Git for developersIntroduction to Git for developers
Introduction to Git for developersDmitry Guyvoronsky
5K views61 slides
Continuous deployment steve povilaitis by
Continuous deployment   steve povilaitisContinuous deployment   steve povilaitis
Continuous deployment steve povilaitisSteve Povilaitis
380 views35 slides
Continuous delivery in Qbon by
Continuous delivery  in QbonContinuous delivery  in Qbon
Continuous delivery in QbonJaric Kuo
365 views18 slides

What's hot(20)

Ansible top 10 - 2018 by Viresh Doshi
Ansible top 10 -  2018Ansible top 10 -  2018
Ansible top 10 - 2018
Viresh Doshi236 views
An Open-Source Chef Cookbook CI/CD Implementation Using Jenkins Pipelines by Steffen Gebert
An Open-Source Chef Cookbook CI/CD Implementation Using Jenkins PipelinesAn Open-Source Chef Cookbook CI/CD Implementation Using Jenkins Pipelines
An Open-Source Chef Cookbook CI/CD Implementation Using Jenkins Pipelines
Steffen Gebert5.3K views
Managing Jenkins with Jenkins (Jenkins User Conference Palo Alto, 2013) by Gareth Bowles
Managing Jenkins with Jenkins (Jenkins User Conference Palo Alto, 2013)Managing Jenkins with Jenkins (Jenkins User Conference Palo Alto, 2013)
Managing Jenkins with Jenkins (Jenkins User Conference Palo Alto, 2013)
Gareth Bowles6.4K views
Continuous deployment steve povilaitis by Steve Povilaitis
Continuous deployment   steve povilaitisContinuous deployment   steve povilaitis
Continuous deployment steve povilaitis
Steve Povilaitis380 views
Continuous delivery in Qbon by Jaric Kuo
Continuous delivery  in QbonContinuous delivery  in Qbon
Continuous delivery in Qbon
Jaric Kuo365 views
An almost complete continuous delivery pipeline including configuration manag... by ulfmansson
An almost complete continuous delivery pipeline including configuration manag...An almost complete continuous delivery pipeline including configuration manag...
An almost complete continuous delivery pipeline including configuration manag...
ulfmansson3.4K views
Continuous Deployment at Etsy: A Tale of Two Approaches by Ross Snyder
Continuous Deployment at Etsy: A Tale of Two ApproachesContinuous Deployment at Etsy: A Tale of Two Approaches
Continuous Deployment at Etsy: A Tale of Two Approaches
Ross Snyder40.2K views
eZ Publish 5: from zero to automated deployment (and no regressions!) in one ... by Gaetano Giunta
eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...
eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...
Gaetano Giunta816 views
Continuous Integration at Mollie by willemstuursma
Continuous Integration at MollieContinuous Integration at Mollie
Continuous Integration at Mollie
willemstuursma2.2K views
Building Evolvable Infrastructure by kiefdotcom
Building Evolvable InfrastructureBuilding Evolvable Infrastructure
Building Evolvable Infrastructure
kiefdotcom34 views
Smarter deployments with octopus deploy by Thibaud Gravrand
Smarter deployments with octopus deploySmarter deployments with octopus deploy
Smarter deployments with octopus deploy
Thibaud Gravrand1.7K views
Continuous integration by hugo lu
Continuous integrationContinuous integration
Continuous integration
hugo lu3.3K views
DevOps 及 TDD 開發流程哲學 by 謝 宗穎
DevOps 及 TDD 開發流程哲學DevOps 及 TDD 開發流程哲學
DevOps 及 TDD 開發流程哲學
謝 宗穎5.1K views
Introduction to jenkins by Abe Diaz
Introduction to jenkinsIntroduction to jenkins
Introduction to jenkins
Abe Diaz12.9K views
Continuous Integration, Build Pipelines and Continuous Deployment by Christopher Read
Continuous Integration, Build Pipelines and Continuous DeploymentContinuous Integration, Build Pipelines and Continuous Deployment
Continuous Integration, Build Pipelines and Continuous Deployment
Christopher Read26.8K views

Similar to Cfg mgmtcamp c-dwithchef

Chef Jumpstart by
Chef JumpstartChef Jumpstart
Chef JumpstartKimball Johnson
136 views134 slides
TYPO3 Camp Stuttgart 2015 - Continuous Delivery with Open Source Tools by
TYPO3 Camp Stuttgart 2015 - Continuous Delivery with Open Source ToolsTYPO3 Camp Stuttgart 2015 - Continuous Delivery with Open Source Tools
TYPO3 Camp Stuttgart 2015 - Continuous Delivery with Open Source ToolsMichael Lihs
2K views67 slides
London Atlassian User Group - February 2014 by
London Atlassian User Group - February 2014London Atlassian User Group - February 2014
London Atlassian User Group - February 2014Steve Smith
11.4K views40 slides
The Key Components of Adopting CI The OpenStack Way by
The Key Components of Adopting CI The OpenStack WayThe Key Components of Adopting CI The OpenStack Way
The Key Components of Adopting CI The OpenStack WayiWeb (group INAP)
716 views42 slides
Steamlining your puppet development workflow by
Steamlining your puppet development workflowSteamlining your puppet development workflow
Steamlining your puppet development workflowTomas Doran
4.5K views36 slides
Puppet Camp New York 2014: Streamlining Puppet Development Workflow by
Puppet Camp New York 2014: Streamlining Puppet Development Workflow Puppet Camp New York 2014: Streamlining Puppet Development Workflow
Puppet Camp New York 2014: Streamlining Puppet Development Workflow Puppet
1.9K views36 slides

Similar to Cfg mgmtcamp c-dwithchef(20)

TYPO3 Camp Stuttgart 2015 - Continuous Delivery with Open Source Tools by Michael Lihs
TYPO3 Camp Stuttgart 2015 - Continuous Delivery with Open Source ToolsTYPO3 Camp Stuttgart 2015 - Continuous Delivery with Open Source Tools
TYPO3 Camp Stuttgart 2015 - Continuous Delivery with Open Source Tools
Michael Lihs2K views
London Atlassian User Group - February 2014 by Steve Smith
London Atlassian User Group - February 2014London Atlassian User Group - February 2014
London Atlassian User Group - February 2014
Steve Smith11.4K views
The Key Components of Adopting CI The OpenStack Way by iWeb (group INAP)
The Key Components of Adopting CI The OpenStack WayThe Key Components of Adopting CI The OpenStack Way
The Key Components of Adopting CI The OpenStack Way
iWeb (group INAP)716 views
Steamlining your puppet development workflow by Tomas Doran
Steamlining your puppet development workflowSteamlining your puppet development workflow
Steamlining your puppet development workflow
Tomas Doran4.5K views
Puppet Camp New York 2014: Streamlining Puppet Development Workflow by Puppet
Puppet Camp New York 2014: Streamlining Puppet Development Workflow Puppet Camp New York 2014: Streamlining Puppet Development Workflow
Puppet Camp New York 2014: Streamlining Puppet Development Workflow
Puppet1.9K views
Emerging chef patterns and practices by Owain Perry
Emerging chef patterns and practicesEmerging chef patterns and practices
Emerging chef patterns and practices
Owain Perry1.3K views
Continuous Delivery Using Jenkins by Cliffano Subagio
Continuous Delivery Using JenkinsContinuous Delivery Using Jenkins
Continuous Delivery Using Jenkins
Cliffano Subagio3.6K views
Source version control using subversion by Mangesh Bhujbal
Source version control using subversionSource version control using subversion
Source version control using subversion
Mangesh Bhujbal449 views
Testing API's: Tools & Tips & Tricks (Oh My!) by Ford Prior
Testing API's: Tools & Tips & Tricks (Oh My!)Testing API's: Tools & Tips & Tricks (Oh My!)
Testing API's: Tools & Tips & Tricks (Oh My!)
Ford Prior153 views
Road to Continuous Delivery - Wix.com by Aviran Mordo
Road to Continuous Delivery - Wix.comRoad to Continuous Delivery - Wix.com
Road to Continuous Delivery - Wix.com
Aviran Mordo3K views
Alm with tfs 2013 by MSDEVMTL
Alm with tfs 2013Alm with tfs 2013
Alm with tfs 2013
MSDEVMTL716 views
DevOps Brisbane Meetup - June - ChefCon 2015 by Michael Villis
DevOps Brisbane Meetup - June - ChefCon 2015DevOps Brisbane Meetup - June - ChefCon 2015
DevOps Brisbane Meetup - June - ChefCon 2015
Michael Villis231 views
Devops journey chefpopup-2016.04.26-v2 by Chef
Devops journey chefpopup-2016.04.26-v2Devops journey chefpopup-2016.04.26-v2
Devops journey chefpopup-2016.04.26-v2
Chef300 views
Testable Infrastructure with Chef, Test Kitchen, and Docker by Mandi Walls
Testable Infrastructure with Chef, Test Kitchen, and DockerTestable Infrastructure with Chef, Test Kitchen, and Docker
Testable Infrastructure with Chef, Test Kitchen, and Docker
Mandi Walls5.5K views
Aki Salmi - Refactoring legacy code: a true story @ I T.A.K.E. Unconference 2... by Mozaic Works
Aki Salmi - Refactoring legacy code: a true story @ I T.A.K.E. Unconference 2...Aki Salmi - Refactoring legacy code: a true story @ I T.A.K.E. Unconference 2...
Aki Salmi - Refactoring legacy code: a true story @ I T.A.K.E. Unconference 2...
Mozaic Works328 views
DevOps in 5 minutes by Jolyon Brown
DevOps in 5 minutesDevOps in 5 minutes
DevOps in 5 minutes
Jolyon Brown1.8K views
Introduction to Automated Testing by Lars Thorup
Introduction to Automated TestingIntroduction to Automated Testing
Introduction to Automated Testing
Lars Thorup1.6K views
Introduction to-automated-testing by BestBrains
Introduction to-automated-testingIntroduction to-automated-testing
Introduction to-automated-testing
BestBrains366 views

Recently uploaded

How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ... by
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...ShapeBlue
171 views28 slides
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda... by
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...ShapeBlue
164 views13 slides
Cencora Executive Symposium by
Cencora Executive SymposiumCencora Executive Symposium
Cencora Executive Symposiummarketingcommunicati21
160 views14 slides
Ransomware is Knocking your Door_Final.pdf by
Ransomware is Knocking your Door_Final.pdfRansomware is Knocking your Door_Final.pdf
Ransomware is Knocking your Door_Final.pdfSecurity Bootcamp
98 views46 slides
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ... by
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...ShapeBlue
129 views10 slides
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ... by
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...ShapeBlue
120 views17 slides

Recently uploaded(20)

How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ... by ShapeBlue
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...
ShapeBlue171 views
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda... by ShapeBlue
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...
ShapeBlue164 views
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ... by ShapeBlue
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...
ShapeBlue129 views
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ... by ShapeBlue
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...
Import Export Virtual Machine for KVM Hypervisor - Ayush Pandey - University ...
ShapeBlue120 views
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R... by ShapeBlue
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...
ShapeBlue178 views
Business Analyst Series 2023 - Week 4 Session 8 by DianaGray10
Business Analyst Series 2023 -  Week 4 Session 8Business Analyst Series 2023 -  Week 4 Session 8
Business Analyst Series 2023 - Week 4 Session 8
DianaGray10145 views
CloudStack Managed User Data and Demo - Harikrishna Patnala - ShapeBlue by ShapeBlue
CloudStack Managed User Data and Demo - Harikrishna Patnala - ShapeBlueCloudStack Managed User Data and Demo - Harikrishna Patnala - ShapeBlue
CloudStack Managed User Data and Demo - Harikrishna Patnala - ShapeBlue
ShapeBlue137 views
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue by ShapeBlue
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlueCloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue
ShapeBlue139 views
The Power of Heat Decarbonisation Plans in the Built Environment by IES VE
The Power of Heat Decarbonisation Plans in the Built EnvironmentThe Power of Heat Decarbonisation Plans in the Built Environment
The Power of Heat Decarbonisation Plans in the Built Environment
IES VE84 views
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue by ShapeBlue
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlueWhat’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue
What’s New in CloudStack 4.19 - Abhishek Kumar - ShapeBlue
ShapeBlue265 views
LLMs in Production: Tooling, Process, and Team Structure by Aggregage
LLMs in Production: Tooling, Process, and Team StructureLLMs in Production: Tooling, Process, and Team Structure
LLMs in Production: Tooling, Process, and Team Structure
Aggregage57 views
The Power of Generative AI in Accelerating No Code Adoption.pdf by Saeed Al Dhaheri
The Power of Generative AI in Accelerating No Code Adoption.pdfThe Power of Generative AI in Accelerating No Code Adoption.pdf
The Power of Generative AI in Accelerating No Code Adoption.pdf
Saeed Al Dhaheri39 views
Future of AR - Facebook Presentation by Rob McCarty
Future of AR - Facebook PresentationFuture of AR - Facebook Presentation
Future of AR - Facebook Presentation
Rob McCarty65 views
"Node.js Development in 2024: trends and tools", Nikita Galkin by Fwdays
"Node.js Development in 2024: trends and tools", Nikita Galkin "Node.js Development in 2024: trends and tools", Nikita Galkin
"Node.js Development in 2024: trends and tools", Nikita Galkin
Fwdays33 views
Optimizing Communication to Optimize Human Behavior - LCBM by Yaman Kumar
Optimizing Communication to Optimize Human Behavior - LCBMOptimizing Communication to Optimize Human Behavior - LCBM
Optimizing Communication to Optimize Human Behavior - LCBM
Yaman Kumar38 views
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT by ShapeBlue
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBITUpdates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT
ShapeBlue208 views
Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And... by ShapeBlue
Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And...Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And...
Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And...
ShapeBlue108 views

Cfg mgmtcamp c-dwithchef

  • 1. So Continuous. Much Delivery. Very Chef. Wow. A Case Study on using Chef to start building a Continuous Delivery Pipeline
  • 2. About Me • George Miranda • Sr Consultant at Chef Software, Inc. • Unix guy (15+ years)
  • 7. What we know • Step 1: Develop a new change • Step 2: ??? • Step 3: Production! • MOAR FASTERZ
  • 8. Case Study: Requirements • Must utilize existing tools within the company • Git for SCM • Jenkins approved for use • Working in a static VM environment • Just migrated to single cookbook repos • Starting with infrastructure cookbooks • Want a manual go-to-production button (ugh!)
  • 9. Case Study: Code Review Model • Git PR model: branch from master for any new feature • 4-person team, only 3 active at any time • Code review done manually and informally • Simple communication/reqs (makes it easy!)
  • 10. Figuring out new workflow • How are developers expected to work locally? • When do they push to remote? How do we verify their work? • Code Review criteria: what does it mean to be ready to merge? • How do we go from merged code to artifact? • How do we get that artifact all the way to Production?
  • 11. Local Development Work • New branch for every feature • Create a failing test • Write a resource to pass the test • Local commits • Test-Kitchen + guard • Once local tests passed, push to remote
  • 12. Push to remote • Open a Pull Request (new branch to master) • Triggers a build via Jenkins GHPRB plugin
  • 13. Push to remote The Verify Build Job • Verify syntax (knife cookbook check) • Foodcritic Rules • Test-Kitchen w/ BATS busser
  • 14. BATS: Simple Unit Tests @test "My directory is created" {! test -d /foo/bar! }! ! @test "A basharific test" {! if [ foo != bar ]; then! skip "foo isn't bar"! fi! ! run foo! [ "$status" -eq 0 ]! }! ! • • https://github.com/sstephenson/bats Super low learning curve (but also very limited)
  • 15. Push to remote • If failed, notify • Another commit to the same branch triggers another Verify Build Job • Super easy to track, comment, and approve • If passed, let’s go to Human Code Review
  • 16. Human Code Review Rules • Only one change per one cookbook at one time • Must have test for feature that changed • One for one: resource unit tests • Consider the smoke test
  • 17. Unit Test vs Smoke Test • Unit tests: small, fast, check one single concern • • Smoke tests: test multiple things in the course of one concern • • In this context: checking Chef resources In this context: check the intent of a recipe Note: that was testing for this use case
  • 18. When are we ready to merge? • Only 3 active team members at any given time • • • Submitter cannot approve Merge approval requires 2 approvals Code review can happen at any time, but only merge when you’re ready to fix it.
  • 19. Merged code to artifact • Freeze your cookbooks! • Semantic versioning: Major.Minor.Patch • • • You own Major.Minor The Pipeline owns .Patch No one gets to knife upload No one.! Ever.! • "git merge" is the new "knife upload"
  • 21. The Integration Job • Bumps Cookbook version • Re-commits to master • Upload frozen cookbook (via berks) • Pin that new cookbook to the Integration environment • Converge all nodes that use that cookbook
  • 22. The Integration Job • First sign that things may be broken • These nodes also run smoke tests • serverspec, minitest, etc
  • 23. The Integration Job • We survived! Trigger the next job(s) • The Jenkins Build Pipelines Plugin allows upstream/downstream definitions to string together jobs • From here out, it’s all the same Promote Job* • After the Integration job, we just run X number of Promote Jobs * (mostly)
  • 27. Promote Jobs • Pin cookbook to new Chef Environment • Converge all nodes using this cookbook • Run Tests
  • 28. Pin the cookbook to Env #!/opt/chef/embedded/bin/ruby ! require 'chef/environment' require 'chef' Chef::Config.from_file("/var/lib/jenkins/tools/knife.rb") ! def pin_env(env, cookbook_versions) to = Chef::Environment.load(env) cookbook_versions.each do |cb, version| puts "Pinning #{cb} #{version} in #{env}" to.cookbook_versions[cb] = version end to.save end ! cookbook_data = Array.new ! if File.exists?(File.expand_path(File.join(ENV['WORKSPACE'], 'metadata.rb'))) metadata_file = File.expand_path(File.join(ENV['WORKSPACE'], 'metadata.rb')) File.read(metadata_file).each_line do |line| if line =~ /^names+["'](w+)["'].*$/ cookbook_data << $1 end if line =~ /^versions+["'](d+.d+.d+)["'].*$/ cookbook_data << "= #{$1}" end end end ! cookbook_versions = Hash[*cookbook_data] ! pin_env(ARGV[0], cookbook_versions)
  • 29. Pin the cookbook to Env $ berks apply <environment>
  • 30. Converge Nodes $ knife ssh "recipes:mycookbook AND chef_environment:promote-environment” 'sudo chef-client'! … OR … Pushy!
  • 31. Run Tests • Most testing frameworks have a Report Handler to automatically run tests • chef-serverspec-handler • minitest-handler • Deploy to your nodes by adding ‘chef_handler’ to their run_list • Many community cookbooks are already packaged with tests
  • 32. Run Tests • In this particular use case: • Build job: BATS (unit tests) • Integration & Promote jobs: serverspec (smoke tests) • UAT: also ran Cucumber tests (acceptance)
  • 34. Promoting to more environments • Can string together N number of promotions • UAT • Production A • Production B • etc
  • 37. Push to Production • In production monitoring is the test • Could not queue up changes reliably anyway • There is no spoon
  • 38. Results • Small incremental deployments led to greater confidence • TDD was pushed to the forefront of priorities • Commitment from Dev group to write application deployment cookbooks • But the biggest lesson learned…
  • 39. Let’s Go Devop with a CD tool • Continuous Delivery is a practice, not a tool • Small incremental changes in code • Small incremental changes in workflow • Small incremental changes in tooling • You will constantly improve your code, your workflow, your tools, your team, and your skills.
  • 40. RECAP
  • 41. What We Wanted • Step 1: Develop a new change • Step 2: ??? • Step 3: Production! • MOAR FASTERZ
  • 42. Wait… what was Step 2? • (Pre-req) Test Driven Development • 2A. Establish development workflow before submitting changes * • 2B. Auto verification of submission before humans look at it • 2C. Humans Apply Code Review Criteria * • 2D. Don’t merge unless you mean it * • 2E. Merge kicks off an Integration Job • 2F. Followed by a series of Promotion Jobs • 2G. There is no spoon *
  • 43. What We Got • • Step 1: Develop a new change Step 2: (Pre-req) Test Driven Development 2A. Establish development workflow before submitting changes * 2B. Auto verification of submission before humans look at it ! 2C. Humans Apply Code Review Criteria * 2D. Don’t merge unless you mean it * 2E. Merge kicks off an Integration Job ! 2F. Followed by a series of Promotion Jobs 2G. There is no spoon * • Step 3: Production! • Step 4: Level Up. This is great! • Step 5: MOAR THINGS! Wait. This is hard! • Go to Step 1
  • 44. Key Chef Ecosystem Tools • Test Kitchen — http://kitchen.ci/ • Guard Plugin for Test Kitchen — https://github.com/test-kitchen/guard-kitchen • Foodcritic — http://acrmp.github.io/foodcritic/ • Berkshelf — http://berkshelf.com/
  • 46. I want to hear from you! ! @gmiranda23 gmiranda@getchef.com