Top Banner
Intro to Chef & Chef Delivery
27

Intro to Chef & Chef Delivery - files.meetup.comfiles.meetup.com/4310272/Chef Delivery.pdf · Overview • Chef is an automation framework that enables Infrastructure as Code •

May 30, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Intro to Chef & Chef Delivery - files.meetup.comfiles.meetup.com/4310272/Chef Delivery.pdf · Overview • Chef is an automation framework that enables Infrastructure as Code •

Intro to Chef & Chef Delivery

Page 2: Intro to Chef & Chef Delivery - files.meetup.comfiles.meetup.com/4310272/Chef Delivery.pdf · Overview • Chef is an automation framework that enables Infrastructure as Code •

Agenda

•  Overview

•  Chef Software Platform

•  Building Blocks

•  Automation Patterns

•  Chef Delivery!

Page 3: Intro to Chef & Chef Delivery - files.meetup.comfiles.meetup.com/4310272/Chef Delivery.pdf · Overview • Chef is an automation framework that enables Infrastructure as Code •

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

Page 4: Intro to Chef & Chef Delivery - files.meetup.comfiles.meetup.com/4310272/Chef Delivery.pdf · Overview • Chef is an automation framework that enables Infrastructure as Code •

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.

Page 5: Intro to Chef & Chef Delivery - files.meetup.comfiles.meetup.com/4310272/Chef Delivery.pdf · Overview • Chef is an automation framework that enables Infrastructure as Code •

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

.)

Page 6: Intro to Chef & Chef Delivery - files.meetup.comfiles.meetup.com/4310272/Chef Delivery.pdf · Overview • Chef is an automation framework that enables Infrastructure as Code •

Building Blocks

Page 7: Intro to Chef & Chef Delivery - files.meetup.comfiles.meetup.com/4310272/Chef Delivery.pdf · Overview • Chef is an automation framework that enables Infrastructure as Code •

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

Page 8: Intro to Chef & Chef Delivery - files.meetup.comfiles.meetup.com/4310272/Chef Delivery.pdf · Overview • Chef is an automation framework that enables Infrastructure as Code •

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

Page 9: Intro to Chef & Chef Delivery - files.meetup.comfiles.meetup.com/4310272/Chef Delivery.pdf · Overview • Chef is an automation framework that enables Infrastructure as Code •

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

Page 10: Intro to Chef & Chef Delivery - files.meetup.comfiles.meetup.com/4310272/Chef Delivery.pdf · Overview • Chef is an automation framework that enables Infrastructure as Code •

Building Blocks

Page 11: Intro to Chef & Chef Delivery - files.meetup.comfiles.meetup.com/4310272/Chef Delivery.pdf · Overview • Chef is an automation framework that enables Infrastructure as Code •

Building Blocks

Page 12: Intro to Chef & Chef Delivery - files.meetup.comfiles.meetup.com/4310272/Chef Delivery.pdf · Overview • Chef is an automation framework that enables Infrastructure as Code •

Automation Patterns

Page 13: Intro to Chef & Chef Delivery - files.meetup.comfiles.meetup.com/4310272/Chef Delivery.pdf · Overview • Chef is an automation framework that enables Infrastructure as Code •

CHEF DELIVERY

Page 14: Intro to Chef & Chef Delivery - files.meetup.comfiles.meetup.com/4310272/Chef Delivery.pdf · Overview • Chef is an automation framework that enables Infrastructure as Code •

VALIDATED IN OUR ENGAGEMENTS WITHENTERPRISE AND BIG WEB CUSTOMERS.

WE'VE IDENTIFIED A PROVEN PIPELINE

U-071982-C

Page 15: Intro to Chef & Chef Delivery - files.meetup.comfiles.meetup.com/4310272/Chef Delivery.pdf · Overview • Chef is an automation framework that enables Infrastructure as Code •

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

Page 16: Intro to Chef & Chef Delivery - files.meetup.comfiles.meetup.com/4310272/Chef Delivery.pdf · Overview • Chef is an automation framework that enables Infrastructure as Code •

A SHARED PIPELINEACROSS PROJECTS AND TEAMS !

Page 17: Intro to Chef & Chef Delivery - files.meetup.comfiles.meetup.com/4310272/Chef Delivery.pdf · Overview • Chef is an automation framework that enables Infrastructure as Code •

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

Page 18: Intro to Chef & Chef Delivery - files.meetup.comfiles.meetup.com/4310272/Chef Delivery.pdf · Overview • Chef is an automation framework that enables Infrastructure as Code •

THE STAGES ARE FIXED

EACH STAGE HAS A FIXED SET OF PHASES

A UNIFIED PIPELINE SHAPE

Page 19: Intro to Chef & Chef Delivery - files.meetup.comfiles.meetup.com/4310272/Chef Delivery.pdf · Overview • Chef is an automation framework that enables Infrastructure as Code •

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

Page 20: Intro to Chef & Chef Delivery - files.meetup.comfiles.meetup.com/4310272/Chef Delivery.pdf · Overview • Chef is an automation framework that enables Infrastructure as Code •

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

Page 21: Intro to Chef & Chef Delivery - files.meetup.comfiles.meetup.com/4310272/Chef Delivery.pdf · Overview • Chef is an automation framework that enables Infrastructure as Code •

PHASE EXECUTION

log "Running unit"

repo = node['delivery_builder']['repo']

execute “run my junit tests" do command "mvn test" cwd repoend

U-071982-C

Page 22: Intro to Chef & Chef Delivery - files.meetup.comfiles.meetup.com/4310272/Chef Delivery.pdf · Overview • Chef is an automation framework that enables Infrastructure as Code •

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 !

Page 23: Intro to Chef & Chef Delivery - files.meetup.comfiles.meetup.com/4310272/Chef Delivery.pdf · Overview • Chef is an automation framework that enables Infrastructure as Code •

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

Page 24: Intro to Chef & Chef Delivery - files.meetup.comfiles.meetup.com/4310272/Chef Delivery.pdf · Overview • Chef is an automation framework that enables Infrastructure as Code •

EASILY CREATE DELIVERY PIPELINES

PROJECT GIT REPOBUILD COOKBOOK

PROJECT CONFIG FILE

U-071982-C

Page 25: Intro to Chef & Chef Delivery - files.meetup.comfiles.meetup.com/4310272/Chef Delivery.pdf · Overview • Chef is an automation framework that enables Infrastructure as Code •

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

Page 26: Intro to Chef & Chef Delivery - files.meetup.comfiles.meetup.com/4310272/Chef Delivery.pdf · Overview • Chef is an automation framework that enables Infrastructure as Code •

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

Page 27: Intro to Chef & Chef Delivery - files.meetup.comfiles.meetup.com/4310272/Chef Delivery.pdf · Overview • Chef is an automation framework that enables Infrastructure as Code •

U-071982-C