CI for Chefs

15
CI for Chefs How to cook successful deployments Author: Nikolay Yurin - @yurinnick

description

Presentation about best practises and continuous integration for Opscode Chef cookbooks

Transcript of CI for Chefs

Page 1: CI for Chefs

CI for ChefsHow to cook successful deployments

Author: Nikolay Yurin - @yurinnick

Page 2: CI for Chefs

Why?

● Code quality

● Portability

● DevOps time saving

Page 3: CI for Chefs

Why?

Because we need stable

deployments, that’s why!

Page 4: CI for Chefs

Deployment testing● Start VM on Vagrant/AWS ~ 1-3 minutes

● Install chef client ~ 1 minute

● Wait for deployment ~ 10 - ∞ minutes

● Check configuration ~ 5 - 30 minutes

Page 5: CI for Chefs

Unacceptable!● About 20 minutes● Manual testing● No info about

current code status

Page 6: CI for Chefs

CI/CD for deployment automation● Unit test for every recipe

● Integration tests for every service

● Automated on-commit builds

● Email notifications

● Release to file storage or Chef Server

Page 7: CI for Chefs

Kitchen set for the better chef● ChefSpec - unit testing for every recipe

● Serverspec - integration testing for server

configurations

● Foodcritic - static code validation

● Docker - fast start/destroy containers

Page 8: CI for Chefs

Foodcritic - verify ingredients

● Tests 45 most common mistakes

● Checks template and variables

● Integrates with Jenkins

Page 9: CI for Chefs

ChefSpec - check recipe ● Test your recipes in RSpec style

● DSL with tons of manuals

Page 10: CI for Chefs

Serverspec - deployment taste

● RSpec syntax again

● SSH or local exec

● Basic Windows

support

Page 11: CI for Chefs

Development workflow

new_recipe.rbspec_new_recipe.rb Foodcritic ChefSpec

Docker container

Chef + Serverspec

Local validation process

Page 12: CI for Chefs

Development workflow

CI Server

Git repository

new commit

fb-static-tests

Foodcritic

ChefSpec

fb-integration-tests

Serverspec

Artifact

Build report

On-commit code validation

Page 13: CI for Chefs

Shut up and setup my CI!● Start writing tests!● Use dependency

manager● Setup CI server● Create centralized

release binary repo

Page 14: CI for Chefs

TDD for Chef

http://www.amazon.com/Test-Driven-Infrastructure-Chef-Behavior-Driven-Development/dp/1449372201

Page 15: CI for Chefs

Questions?Nikolay Yurin - @yurinnick - [email protected]