infrastructure as code with chef / puppet

69
Infrastructure as Code with Chef / Puppet Edmund Haselwanter ([email protected] ) Samstag, 16. November 13

Upload: edmund-haselwanter

Post on 27-Jan-2015

110 views

Category:

Technology


2 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Infrastructure as Code with Chef / Puppet

Infrastructure as Code with Chef / Puppet

Edmund Haselwanter ([email protected])

Samstag, 16. November 13

Page 2: Infrastructure as Code with Chef / Puppet

cloudbau

Edmund Haselwanter

●Co-Founder and CSO cloudbau GmbH

●Dell Professional Services (Openstack/Crowbar/Automation)

●So!ware Development Background

●10 Years Infrastructure Automation

●@ehaselwanter on twitter/github/irc/...

Introduction

Samstag, 16. November 13

Page 3: Infrastructure as Code with Chef / Puppet

cloudbau

Business-Agility needs IT-Agility

„IT REVOLUTION MANIFESTO“, http://itrevolution.com

For most companies, IT functions as the nervous system and provides an increasing amount of the organizational muscle mass. Most critical business functions are entirely automated within IT, and 95% of all capital projects depend on IT to get done. Today, nearly every business decision will result in at least one IT change.

Gene Kim, Kevin Behr, George Spafford, 2013

E.M. Goldratt, 1984

Theory of Constraints → →

Samstag, 16. November 13

Page 4: Infrastructure as Code with Chef / Puppet

cloudbau

IT-Agility and the „Risk of Change“

The core, chronic con!ict that every IT leader faces is the need to simultaneously enable faster time to market (i.e., make as many changes as you can), while providing stable, secure and reliable IT services (i.e., make as few changes as you can). 

„Lowering risk of change through tools and culture“John Allspaw, Paul Hammond, 2009

small changes, o!en

reproducible

process standards

Request Approve

Test Deploy

Develop

Water-

Scrum

- FallGene Kim

expect failure

cooperative culture

metrics

Samstag, 16. November 13

Page 5: Infrastructure as Code with Chef / Puppet

cloudbau

Tools and Culture

CPU-Virt.

Storage-Virt.

SDN

Con!g-DB

Programmable Infrastructure Description in Code

Process and Culture

Continuos Delivery

DevOpsCross-Functional Teams

Automatic Build

Anti-Fragile Organizations

Binary-Repo DescriptionOrchestration

Prod Env Stage Env Dev Env

Samstag, 16. November 13

Page 6: Infrastructure as Code with Chef / Puppet

cloudbau

Con!guration Management

Samstag, 16. November 13

Page 7: Infrastructure as Code with Chef / Puppet

cloudbau

●Just build it

●Keep notes in server.txt

●Move notes to the wiki

●Custom scripts (in scm?!)

●Snapshot & Clone

Evolving towards Con!guration Management

Samstag, 16. November 13

Page 9: Infrastructure as Code with Chef / Puppet

cloudbau

Infrastructure

http://www."ickr.com/photos/sbh/462754460/

Samstag, 16. November 13

Page 10: Infrastructure as Code with Chef / Puppet

cloudbau

Collection of Resources

http://www."ickr.com/photos/philliecasablanca/3354734116/

• Networking

• Files

• Directories

• Symlinks

• Mounts

• Routes

• Users

• Groups

• Tasks

• Packages

• Software

• Services

• Configuration

• Other Stuff

Samstag, 16. November 13

Page 11: Infrastructure as Code with Chef / Puppet

cloudbau

Acting in Concert

http://www."ickr.com/photos/glowjangles/4081048126/

Samstag, 16. November 13

Page 12: Infrastructure as Code with Chef / Puppet

cloudbau

To Provide a Service

http://www."ickr.com/photos/28309157@N08/3743455858/

Samstag, 16. November 13

Page 13: Infrastructure as Code with Chef / Puppet

cloudbau

And it Evolves

http://www."ickr.com/photos/16339684@N00/2681435235/

Samstag, 16. November 13

Page 14: Infrastructure as Code with Chef / Puppet

cloudbau

Application Server

See Node

Samstag, 16. November 13

Page 15: Infrastructure as Code with Chef / Puppet

cloudbau

Application Server

Application Database

See Nodes

Samstag, 16. November 13

Page 16: Infrastructure as Code with Chef / Puppet

cloudbau

Application Server

Application Databases

See Nodes Grow

Samstag, 16. November 13

Page 17: Infrastructure as Code with Chef / Puppet

cloudbau

Application Servers

Application Databases

See Nodes Grow

Samstag, 16. November 13

Page 18: Infrastructure as Code with Chef / Puppet

cloudbau

Application Servers

Application Databases

Load Balancer

See Nodes Grow

Samstag, 16. November 13

Page 19: Infrastructure as Code with Chef / Puppet

cloudbau

Application Servers

Application Databases

Load Balancers

See Nodes Grow

Samstag, 16. November 13

Page 20: Infrastructure as Code with Chef / Puppet

cloudbau

Application Servers

Application Database Cache

Load Balancers

Application Databases

See Nodes Grow

Samstag, 16. November 13

Page 21: Infrastructure as Code with Chef / Puppet

cloudbau

Application Servers

Application Database Cache

Load Balancers

Application Databases

Tied Together with Con!guration

Samstag, 16. November 13

Page 22: Infrastructure as Code with Chef / Puppet

cloudbau

So when this

Jboss App

Memcache

Postgres Slaves

Postgres Master

NagiosGraphite

Samstag, 16. November 13

Page 23: Infrastructure as Code with Chef / Puppet

cloudbau

Becomes This

Jboss App

Memcache

Postgres Slaves

Postgres Master

NagiosGraphite

Samstag, 16. November 13

Page 24: Infrastructure as Code with Chef / Puppet

cloudbau

This can happen automagically

Jboss App

Memcache

Postgres Slaves

Postgres Master

NagiosGraphite

Samstag, 16. November 13

Page 25: Infrastructure as Code with Chef / Puppet

cloudbau

Count the Resources

NagiosGraphite

Jboss App

Memcache

Postgres Slaves

• Load balancer config

• Nagios host ping

• Nagios host ssh

• Nagios host HTTP

• Nagios host app health

• Graphite CPU

• Graphite Memory

• Graphite Disk

• Graphite SNMP

• Memcache firewall

• Postgres firewall

• Postgres authZ config

• 12+ resource changes for 1 node addition

Samstag, 16. November 13

Page 26: Infrastructure as Code with Chef / Puppet

cloudbau

Focus Today: Chef and Puppet

Series A: 2,5 M$ (2009)Series B: 11 M$ (2010)

Series C: 19,5 M$ (2012)

Technologie

Series A: 2 M$ (2009)Series B: 5 M$ (2010)

Series C: 8,5 M$ (2011)Series D: 30 M$ (2013)

Technologie

*alle Angaben von www.crunchbase.com

Samstag, 16. November 13

Page 27: Infrastructure as Code with Chef / Puppet

cloudbau

Chef & Puppet

since 2005 since 2009

Declarative DSL Ruby DSL

Customers: Customers:

• CERN • AWS (OpsWorks)

• Twitter • Facebook

• Zynga • SAP

•VMware • IBM (Smartcloud)

• Microso#

Samstag, 16. November 13

Page 28: Infrastructure as Code with Chef / Puppet

cloudbau

What is Chef?

Recipes and Cookbooks that describe and deliver code.

Chef enables people to easily build & manage complex & dynamic applications at massive scale.

• New model for describing infrastructure that promotes reuse

•  Programmatically provision and configure • Reconstruct business from code repository,

data backup, and bare metal resources

Chef is an IT automation platform for developers & systems engineers to continuously define, build, and manage infrastructure.

CHEF USES:

“!”!

What is Chef?

Recipes and Cookbooks that describe and deliver code.

Chef enables people to easily build & manage complex & dynamic applications at massive scale.

• New model for describing infrastructure that promotes reuse

•  Programmatically provision and configure • Reconstruct business from code repository,

data backup, and bare metal resources

Chef is an IT automation platform for developers & systems engineers to continuously define, build, and manage infrastructure.

CHEF USES:

“!”!

What is Chef?

Recipes and Cookbooks that describe and deliver code.

Chef enables people to easily build & manage complex & dynamic applications at massive scale.

• New model for describing infrastructure that promotes reuse

•  Programmatically provision and configure • Reconstruct business from code repository,

data backup, and bare metal resources

Chef is an IT automation platform for developers & systems engineers to continuously define, build, and manage infrastructure.

CHEF USES:

“!”!

What is Chef?

Recipes and Cookbooks that describe and deliver code.

Chef enables people to easily build & manage complex & dynamic applications at massive scale.

• New model for describing infrastructure that promotes reuse

•  Programmatically provision and configure • Reconstruct business from code repository,

data backup, and bare metal resources

Chef is an IT automation platform for developers & systems engineers to continuously define, build, and manage infrastructure.

CHEF USES:

“!”!

Samstag, 16. November 13

Page 29: Infrastructure as Code with Chef / Puppet

cloudbau

What is Chef?

Recipes and Cookbooks that describe and deliver code.

Chef enables people to easily build & manage complex & dynamic applications at massive scale.

• New model for describing infrastructure that promotes reuse

•  Programmatically provision and configure • Reconstruct business from code repository,

data backup, and bare metal resources

Chef is an IT automation platform for developers & systems engineers to continuously define, build, and manage infrastructure.

CHEF USES:

“!”!

What is Chef?

Recipes and Cookbooks that describe and deliver code.

Chef enables people to easily build & manage complex & dynamic applications at massive scale.

• New model for describing infrastructure that promotes reuse

•  Programmatically provision and configure • Reconstruct business from code repository,

data backup, and bare metal resources

Chef is an IT automation platform for developers & systems engineers to continuously define, build, and manage infrastructure.

CHEF USES:

“!”!

What is Chef?

Recipes and Cookbooks that describe and deliver code.

Chef enables people to easily build & manage complex & dynamic applications at massive scale.

• New model for describing infrastructure that promotes reuse

•  Programmatically provision and configure • Reconstruct business from code repository,

data backup, and bare metal resources

Chef is an IT automation platform for developers & systems engineers to continuously define, build, and manage infrastructure.

CHEF USES:

“!”!

Samstag, 16. November 13

Page 30: Infrastructure as Code with Chef / Puppet

cloudbau

Samstag, 16. November 13

Page 31: Infrastructure as Code with Chef / Puppet

cloudbau

Puppet is IT automation so"ware that helps system administrators manage infrastructure throughout its lifecycle, from provisioning and con$guration to orchestration and reporting.

What is Puppet?

How Puppet WorksPuppet uses a declarative, model-based approach to IT automation.

1. Define the desired state of the infrastructure's configuration using Puppet's declarative configuration language.

2. Simulate configuration changes before enforcing them.

3. Enforce the deployed desired state automatically, correcting any configuration drift.

4. Report on the differences between actual and desired states and any changes made enforcing the desired state.

Samstag, 16. November 13

Page 32: Infrastructure as Code with Chef / Puppet

cloudbau

What is Chef?

Recipes and Cookbooks that describe and deliver code.

Chef enables people to easily build & manage complex & dynamic applications at massive scale.

• New model for describing infrastructure that promotes reuse

•  Programmatically provision and configure • Reconstruct business from code repository,

data backup, and bare metal resources

Chef is an IT automation platform for developers & systems engineers to continuously define, build, and manage infrastructure.

CHEF USES:

“!”!

What is Chef?

Recipes and Cookbooks that describe and deliver code.

Chef enables people to easily build & manage complex & dynamic applications at massive scale.

• New model for describing infrastructure that promotes reuse

•  Programmatically provision and configure • Reconstruct business from code repository,

data backup, and bare metal resources

Chef is an IT automation platform for developers & systems engineers to continuously define, build, and manage infrastructure.

CHEF USES:

“!”!

What is Chef?

Recipes and Cookbooks that describe and deliver code.

Chef enables people to easily build & manage complex & dynamic applications at massive scale.

• New model for describing infrastructure that promotes reuse

•  Programmatically provision and configure • Reconstruct business from code repository,

data backup, and bare metal resources

Chef is an IT automation platform for developers & systems engineers to continuously define, build, and manage infrastructure.

CHEF USES:

“!”!

Samstag, 16. November 13

Page 33: Infrastructure as Code with Chef / Puppet

cloudbau

Samstag, 16. November 13

Page 34: Infrastructure as Code with Chef / Puppet

cloudbau

Concepts

Samstag, 16. November 13

Page 35: Infrastructure as Code with Chef / Puppet

cloudbau

Declarative Language

File 1

Package A

Service IPackage B

Template 1

Samstag, 16. November 13

Page 36: Infrastructure as Code with Chef / Puppet

cloudbau

Convergence to desired State

File 1

Package A

Service IPackage B

Template 1

File 1

Package A

“run”

State X State Y

Samstag, 16. November 13

Page 37: Infrastructure as Code with Chef / Puppet

cloudbau

Idempotence

File 1

Package A

Service IPackage B

Template 1

“run”

State Y State Y

File 1

Package A

Service IPackage B

Template 1

Samstag, 16. November 13

Page 38: Infrastructure as Code with Chef / Puppet

cloudbau

The Implementations

Puppet and Chef

Samstag, 16. November 13

Page 39: Infrastructure as Code with Chef / Puppet

cloudbau

Terminology

Java Puppet Chef

*.java manifests *.pp recipes *.rb

package module cookbook

Samstag, 16. November 13

Page 40: Infrastructure as Code with Chef / Puppet

cloudbau

Terminology

Java Puppet Chef

singleton parametrized classes

recipes with attributes

class de#nes, classes de#nitions, libraries

Samstag, 16. November 13

Page 41: Infrastructure as Code with Chef / Puppet

cloudbau

Syntax

Puppet Chef

Limited DSL (by design) DSL + full ruby

Extended by De!nitionsDe!nitions, Resource/Providers, Light

Weight Resource

Custom Resource providersDe!nitions, Resource/Providers, Light

Weight Resource

ERB & Custom Libraries Providers, Libraries

Samstag, 16. November 13

Page 42: Infrastructure as Code with Chef / Puppet

cloudbau

Syntax Examples

Puppet Chef

class myapache { package “apache2” service “apache2”: ensure => “running”, require => Package[“apache2”]}

package “apache2”

service “apache2 do action [:enable , :start]end

Samstag, 16. November 13

Page 43: Infrastructure as Code with Chef / Puppet

cloudbau

Variables

Puppet Chef

#special syntax

$bla = “aa”

#string interpolation

$bla_string = “${bla}”

#native ruby

bla = “aa”

#string interpolation

bla_string = #{bla}

Samstag, 16. November 13

Page 44: Infrastructure as Code with Chef / Puppet

cloudbau

Loops

Puppet Chef

pass array of elements

erb template for loops

create_resource (:type, hash)

do while , repeat etc. available through native ruby

Samstag, 16. November 13

Page 45: Infrastructure as Code with Chef / Puppet

cloudbau

Conditionals

Puppet (since 2.7) Chef

if

case (execute block)

selectors (get value)

if, unless, case etc. available through native ruby

Samstag, 16. November 13

Page 46: Infrastructure as Code with Chef / Puppet

cloudbau

Project Structure

Puppet Modules Chef

files/

lib/

README.rdoc

manifests/

templates/

attributes/

definitions/

files/

libraries/

metadata.rb

providers/

README.rdoc

recipes/

resources/

templates/

Samstag, 16. November 13

Page 47: Infrastructure as Code with Chef / Puppet

cloudbau

Execution Model

Puppet Chef

Compile catalog (directed graph model) Then Execute Top Down execution

only code for state transition is visited every line of code is visited all the time

Samstag, 16. November 13

Page 48: Infrastructure as Code with Chef / Puppet

cloudbau

Execution Model

Puppet Chef

standalone standalone

client - serverclient - server

hosted

Samstag, 16. November 13

Page 49: Infrastructure as Code with Chef / Puppet

cloudbau

System Information

Puppet/Factor => Flat Key/Value

"hostname": "server-1", "fqdn": "server-1.example.com", "domain": "example.com", "network": { "interfaces": { "eth0": { "type": "eth", "number": "0", "encapsulation": "Ethernet", "addresses": { "00:0C:29:43:26:C5": { "family": "lladdr" }, "192.168.177.138": { "family": "inet", "broadcast": "192.168.177.255", "netmask": "255.255.255.0" },

Chef/Ohai => Nested Hash

Samstag, 16. November 13

Page 50: Infrastructure as Code with Chef / Puppet

cloudbau

●Selects Package Provider

●Selects Service Provider

●....

System Information

Samstag, 16. November 13

Page 51: Infrastructure as Code with Chef / Puppet

cloudbau

System Information (Chef Example)

execute "load sysctl" do command "/sbin/sysctl -p" action :nothingend

bytes = node['memory']['total'].split("kB")[0].to_i * 1024 / 3,pages = node['memory']['total'].split("kB")[0].to_i * 1024 / 3 / 2048

# adjust shared memory and semaphorestemplate "/etc/sysctl.conf" do source "sysctl.conf.erb" variables( :shmmax_in_bytes => bytes, :shmall_in_pages => pages ) notifies :run, "execute[load sysctl]", :immediatelyend

Samstag, 16. November 13

Page 52: Infrastructure as Code with Chef / Puppet

cloudbau

Templates

# Set up application listeners here.

listen application 0.0.0.0:80 balance roundrobin <% @pool_members.each do |member| -%> server <%= member[:hostname] %> <%= member[:ipaddress] %>:> weight 1 maxconn 1 check <% end -%><% if node["haproxy"]["enable_admin"] -%>listen admin 0.0.0.0:22002 mode http stats uri /<% end -%>

Samstag, 16. November 13

Page 53: Infrastructure as Code with Chef / Puppet

cloudbau

Lint Tools

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

http://puppet-lint.com/

Samstag, 16. November 13

Page 54: Infrastructure as Code with Chef / Puppet

cloudbau

Dependency Managementhttps://github.com/applicationsonline/librarian-chef

http://librarian-puppet.com

http://berkshelf.com

Samstag, 16. November 13

Page 55: Infrastructure as Code with Chef / Puppet

cloudbau

Reports

Samstag, 16. November 13

Page 56: Infrastructure as Code with Chef / Puppet

cloudbau

Web Interface

Samstag, 16. November 13

Page 57: Infrastructure as Code with Chef / Puppet

cloudbau

●Razor for bare metal provisioning

●mcollectiv for remote execution/orchestration

●test-kitchen for infrastructure testing

●vagrant for rapid development

● ....

Tools

Samstag, 16. November 13

Page 58: Infrastructure as Code with Chef / Puppet

cloudbau

●Switch Con#g

●Driven by SDN Adoption

●Lots of Vendors (Arista ..)

Networking

Samstag, 16. November 13

Page 59: Infrastructure as Code with Chef / Puppet

cloudbau

Community

Samstag, 16. November 13

Page 60: Infrastructure as Code with Chef / Puppet

cloudbau

Chef Community

Community Overview!

25,000+ Community Members!!

1,000+ Community "Cookbooks!

!250,000+ Cookbook

Downloads!!

400+ Public Training Attendees in the last year!

!30+ Meetup Groups!

!

Over 200 Corporate Contributors

Samstag, 16. November 13

Page 61: Infrastructure as Code with Chef / Puppet

cloudbau

http://community.opscode.com/cookbooks

approx 1200 co0kbooks134 maintained by Opscode

Samstag, 16. November 13

Page 62: Infrastructure as Code with Chef / Puppet

cloudbau

http://forge.puppetlabs.com

approx 1700 modules72 maintained by Puppetlabs

Samstag, 16. November 13

Page 63: Infrastructure as Code with Chef / Puppet

cloudbau

The Price Tag

Samstag, 16. November 13

Page 64: Infrastructure as Code with Chef / Puppet

cloudbau

Puppet: How to BuyCumulative # of

NodesPer Node

Standard SupportPer Node Premium

Support*1-10 Download FREE NA

11-99 $ 99 Contact Sales

100-249 $ 93 Contact Sales

250-499 $ 88 $ 152

500-999 $ 83 $ 119

1000-2499 $ 79 $ 99

2500+ Contact Sales Contact Saleshttps://puppetlabs.com/puppet/how-to-buy

Samstag, 16. November 13

Page 65: Infrastructure as Code with Chef / Puppet

cloudbau

Puppet Enterprise vs. OpenSource

Samstag, 16. November 13

Page 66: Infrastructure as Code with Chef / Puppet

cloudbau

Chef: How to Buy

Free Launch Standard Premium

Price per Month Free $ 120 $ 300 $ 600

Nodes 5 20 50 100

Standard Support — ✔ ✔ ✔

http://www.opscode.com/enterprise-chef/#plans-pricing

Samstag, 16. November 13

Page 67: Infrastructure as Code with Chef / Puppet

cloudbau

Enterprise Chef vs. OpenSource Chef

Samstag, 16. November 13

Page 68: Infrastructure as Code with Chef / Puppet

Danke!

Edmund Haselwanter

@[email protected]+49 30 57701800www.cloudbau.de

cloudbau GmbHKörnerstr. 7-1010785 Berlin

cloudbau

Samstag, 16. November 13

Page 69: Infrastructure as Code with Chef / Puppet

Credits:• Patrick Debois (http://www.jedi.be/blog/) for some of his Puppet/Chef Slides• Opscode (http://www.opscode.com) for product info and some slides • Puppetlabs (http://puppetlabs.com) for product info

Samstag, 16. November 13