Code but now as we know it - Devoxx edition

111
Infrastructure as Code Patrick Debois http://www.tumblr.com/tagged/star-trek-quotes Thursday 15 November 12

description

Comparing config management systems with 'regular' code. Contains a lot of tools and hightlights known and some more obscure existing tools in the space.

Transcript of Code but now as we know it - Devoxx edition

Page 1: Code but now as we know it - Devoxx edition

Infrastructure as Code Patrick Deboishttp://www.tumblr.com/tagged/star-trek-quotes

Thursday 15 November 12

Page 2: Code but now as we know it - Devoxx edition

Blog: http://jedi.be/blog - Twitter : @patrickdebois - #devops

Technical ReviewerMonitoring Chapter Co-Author Veewee / Sahara / Mccloud

Organizer Since 2009 Europe Organizer 2010

Engineer

First Europe Training 2010

Libvirt - Fog

Speaker

Freelance consultant http://github.com/jedi4ever

Thursday 15 November 12

Page 3: Code but now as we know it - Devoxx edition

CONFIGURATION MANAGEMENT SYSTEMS

http://ansible.cc/

http://opscode.com/chef/

http://cfengine.com/http://palletops.com/http://puppetlabs.com/

Thursday 15 November 12

Page 4: Code but now as we know it - Devoxx edition

http://www.nerdnirvana.org/wp-content/uploads/2010/12/apology-form.jpg

Chef & Puppet focusedbased on my experience

Thursday 15 November 12

Page 5: Code but now as we know it - Devoxx edition

SERVICE

FILE2

FILE1PACKAGE

DECLARATIVE LANGUAGE

Thursday 15 November 12

Page 6: Code but now as we know it - Devoxx edition

“KNOWN STATE”

STATE X STATE YCODE RUN

FILE1SERVICE

FILE2

FILE1PACKAGE

convergence

Thursday 15 November 12

Page 7: Code but now as we know it - Devoxx edition

“IDEMPOTENCE”

STATE Y STATE YCODE RUN

SERVICE

FILE2

FILE1PACKAGE

SERVICE

FILE2

FILE1PACKAGE

Thursday 15 November 12

Page 8: Code but now as we know it - Devoxx edition

GIVE ME THE CODE:“LANGUAGE”

Thursday 15 November 12

Page 9: Code but now as we know it - Devoxx edition

Puppet Chef

class myapache {

package “apache2”

service “apache2”: ensure => “running”, require => Package[“apache2”]

}

package “apache2”

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

EXAMPLE SYNTAX

Thursday 15 November 12

Page 10: Code but now as we know it - Devoxx edition

TERMINOLOGY

Java Puppet Chef

*.javamanifests

*.pprecipes

*.rb

package module cookbook

Thursday 15 November 12

Page 11: Code but now as we know it - Devoxx edition

TERMINOLOGY (2)

Java Puppet Chef

singletonparametrized

classesrecipes with attributes

classdefines, classes

definitions, libraries

Thursday 15 November 12

Page 12: Code but now as we know it - Devoxx edition

SYNTAXPuppet Chef

Limited DSL(by design) DSL + full ruby

Extended by Definitions

Light Weight Resource Providers /

DefinitionsCustom Resource providers

Providers, Light Weight Resource

ProvidersERB & Custom Libraries Libraries

Thursday 15 November 12

Page 13: Code but now as we know it - Devoxx edition

LOOPING CONSTRUCTS

Puppet Chef

pass array of elementserb template for loops

create_resource (:type, hash)

do while , repeat etc. available through

native ruby

Thursday 15 November 12

Page 14: Code but now as we know it - Devoxx edition

VARIABLES

Puppet Chef

special syntax$bla = “aa”

string interpolation$bla_string = “${bla}”

native rubybla = “aa”

string interpolationbla_string = #{bla}

Thursday 15 November 12

Page 15: Code but now as we know it - Devoxx edition

SINGLE CLASSINHERITANCE

Puppet Chef

override via ‘module path’

override via ‘cookbook’ path

+> operator “cookbook” attribute

Thursday 15 November 12

Page 16: Code but now as we know it - Devoxx edition

Puppet Module Chef Cookbook

files/lib/

README.rdocmanifests/templates/

attributes/definitions/files/libraries/metadata.rbproviders/README.rdocrecipes/resources/templates/

PROJECT STRUCTURE

Thursday 15 November 12

Page 17: Code but now as we know it - Devoxx edition

EXECUTION MODEL

Puppet Chef

Compile catalog(directed graph

model)Then Execute

Top Down execution

Thursday 15 November 12

Page 18: Code but now as we know it - Devoxx edition

PLUGINSPuppet Chef

FACES KNIFE PLUGINS

REPORTS REPORT HANDLERS

http://puppetlabs.com/blog/puppet-faces-what-the-heck-are-faces/http://wiki.opscode.com/display/chef/Knife+Plugins

Thursday 15 November 12

Page 19: Code but now as we know it - Devoxx edition

CODE EDITOR

Thursday 15 November 12

Page 20: Code but now as we know it - Devoxx edition

https://github.com/rodjek/puppet-pygments-lexerhttp://redmine.djagios.org/projects/puppet-lexer

LEXERS

Thursday 15 November 12

Page 21: Code but now as we know it - Devoxx edition

VIM SYNTAX HIGHLIGHTIING

https://github.com/rodjek/vim-puppethttps://github.com/t9md/vim-chef

https://github.com/vim-scripts/Cfengine-version-3-syntax

Thursday 15 November 12

Page 22: Code but now as we know it - Devoxx edition

http://cloudsmith.github.com/geppetto/https://github.com/cloudsmith/geppetto

GEPPETTO - ECLIPSE IDE

Thursday 15 November 12

Page 23: Code but now as we know it - Devoxx edition

JETBRAINS RUBYMINE (PUPPET)http://youtrack.jetbrains.com/issue/RUBY-10832

REACTOR8http://beta.r8network.com/

COMING SOON

https://github.com/janschumann/intellij-lang-puppet

Thursday 15 November 12

Page 24: Code but now as we know it - Devoxx edition

REVERSE ENGINEERING

https://github.com/devstructure/blueprint

Existing Server -> Manifest/Recipes

Thursday 15 November 12

Page 25: Code but now as we know it - Devoxx edition

CODING STYLE

Thursday 15 November 12

Page 26: Code but now as we know it - Devoxx edition

Puppet Chef

http://puppet-lint.com/ http://acrmp.github.com/foodcritic/

• Must use two-space soft tabs.• Must not use literal tab characters.• Must not contain trailing white space.• Should not exceed an 80 character line width

An exception has been made for source  =>  'puppet://...' lines as splitting these over multiple lines decreases the readability of the manifests.

• Should align arrows (=>) within blocks of attributes.• ....

• FC001: Use strings in preference to symbols to access node attributes• FC002: Avoid string interpolation where not required• FC003: Check whether you are running with chef server before using server-

specific features• FC004: Use a service resource to start and stop services• FC005: Avoid repetition of resource declarations• FC006: Mode should be quoted or fully specified when setting file

permissions• FC007: Ensure recipe dependencies are reflected in cookbook metadata• FC008: Generated cookbook metadata needs updating• FC009: Resource attribute not recognised• FC010: Invalid search syntax• FC011: Missing README in markdown format• FC012: Use Markdown for README rather than RDoc• FC013: Use file_cache_path rather than hard-coding tmp paths•

http://docs.puppetlabs.com/guides/style_guide.htmlhttps://github.com/ampledata/cookbook-style-guide

Thursday 15 November 12

Page 28: Code but now as we know it - Devoxx edition

CODE VS CONFIG(THINK “PROFILES”)

http://wiki.opscode.com/display/chef/Data+Bags

http://projects.puppetlabs.com/projects/hierahttps://github.com/crayfishx/hiera-gpg

Thursday 15 November 12

Page 30: Code but now as we know it - Devoxx edition

PRE-COMMIT CHECKS

Thursday 15 November 12

Page 31: Code but now as we know it - Devoxx edition

DEPENDENCY MGMT

GitSubmodules

Subtree à la Pom File

Thursday 15 November 12

Page 32: Code but now as we know it - Devoxx edition

UPSTREAM REPOS

http://forge.puppetlabs.com/http://community.opscode.com/

Thursday 15 November 12

Page 33: Code but now as we know it - Devoxx edition

Puppet Chef

https://github.com/rodjek/librarian-puppet

https://github.com/applicationsonline/librarian

http://berkshelf.com/

site  "http://community.opscode.com/api/v1"

cookbook  "ntp"cookbook  "timezone",  "0.0.1"

cookbook  "rvm",    :git  =>  "https://github.com/fnichol/chef-­‐rvm",    :ref  =>  "v0.7.1"

cookbook  "cloudera",    :path  =>  "vendor/cookbooks/cloudera-­‐cookbook"

Thursday 15 November 12

Page 34: Code but now as we know it - Devoxx edition

CHEF METADATA

Thursday 15 November 12

Page 35: Code but now as we know it - Devoxx edition

http://bitfieldconsulting.com/puppet-dependency-graphs

Dependency Graphs

https://github.com/miketheman/knife-role-spaghettiThursday 15 November 12

Page 36: Code but now as we know it - Devoxx edition

http://wham.cloudsmith.com

Online Service

Thursday 15 November 12

Page 37: Code but now as we know it - Devoxx edition

DEBUGGING

Thursday 15 November 12

Page 38: Code but now as we know it - Devoxx edition

LOGGING WITH DIFFERENT LEVELS

Info only, no exceptionChef::Log.info('Some  useful  info')

Fatal, raising exceptionChef::Log.fatal('Something  bad')

Thursday 15 November 12

Page 39: Code but now as we know it - Devoxx edition

REPL - STYLE(READ EVAL PRINT)

http://wiki.opscode.com/display/chef/Shefhttps://github.com/pry/pry

Thursday 15 November 12

Page 40: Code but now as we know it - Devoxx edition

https://github.com/vimeo/simple-black-boxThursday 15 November 12

Page 41: Code but now as we know it - Devoxx edition

DEV ENVIRONMENT

Thursday 15 November 12

Page 42: Code but now as we know it - Devoxx edition

SERVICE

FILE2

FILE1PACKAGE

Virtual Machine (1)

Just Enough Operating System+ Config Management Tool

Virtual Machine ... N

Your laptop (Linux, Wind

virtualization

Thursday 15 November 12

Page 43: Code but now as we know it - Devoxx edition

SERVICE

FILE2

FILE1PACKAGE

Virtual Machine (1)

Just Enough Operating System+ Config Management Tool

Your Laptopvirtualization

http://vagrantup.com/

Virtualbox + (Fusion Soon)

Linux & WindowsThursday 15 November 12

Page 45: Code but now as we know it - Devoxx edition

http://marketplace.eclipse.org/node/519961#.UKISB-Oe-d4

VAGRANT ECLIPSE INTEGRATION

Thursday 15 November 12

Page 46: Code but now as we know it - Devoxx edition

https://github.com/rtyler/blimpy

https://github.com/jedi4ever/mccloud/

Vagrant ‘clones’

EC2, KVM, FUSION,HOSTS, Vagrant

EC2

https://github.com/neerolyte/vagueanthttps://github.com/lstoll/tenderloin FUSION

LXC

Thursday 15 November 12

Page 47: Code but now as we know it - Devoxx edition

VAGRANT - CLOJURE

https://github.com/tbatchelli/vmfestThursday 15 November 12

Page 48: Code but now as we know it - Devoxx edition

VAGRANT - JAVA

https://github.com/guigarage/vagrant-bindingThursday 15 November 12

Page 49: Code but now as we know it - Devoxx edition

JEOS CREATION

Just Enough Operating System+ Config Management Tool

Your Laptopvirtualization

Virtualbox , FusionKVM, Parallels

Linux & Windows

https://github.com/jedi4ever/veewee/

Centos, Ubuntu, Debian, Solaris, Gentoo, Suse, Oracle Linux, ....

And windows now too!

Thursday 15 November 12

Page 52: Code but now as we know it - Devoxx edition

UNIT TESTING

Thursday 15 November 12

Page 53: Code but now as we know it - Devoxx edition

https://github.com/nistude/cucumber-puppetThursday 15 November 12

Page 54: Code but now as we know it - Devoxx edition

https://github.com/rodjek/rspec-puppet

https://github.com/calavera/rspec-chefhttps://github.com/acrmp/chefspec

Thursday 15 November 12

Page 55: Code but now as we know it - Devoxx edition

DON’T TEST YOUR CONFIG MANAGEMENT

TEST YOUR LOGIC

NOT

Was the package installed

YES

If (OS=’X’ ) and (file exists) ...

did it give an error?

Thursday 15 November 12

Page 56: Code but now as we know it - Devoxx edition

FAKE THE FACTSThursday 15 November 12

Page 57: Code but now as we know it - Devoxx edition

https://github.com/customink/fauxhaiThursday 15 November 12

Page 58: Code but now as we know it - Devoxx edition

AUTO-TRIGGER TESTS RUN

https://github.com/guard/guard-chefhttps://github.com/alister/guard-puppet-linthttps://github.com/johnbintz/guard-puppet

https://github.com/guard/guard-rspec

CODE EDIT

AUTO RUNFEEDBACK

Thursday 15 November 12

Page 59: Code but now as we know it - Devoxx edition

LOCAL VM TESTING

http://www.cucumber-chef.org/

https://github.com/exceedhl/toft

Faster testing via LXC

spinning up a vm is expensiveunless in container

EC2+LXC

Vagrant+LXCThursday 15 November 12

Page 60: Code but now as we know it - Devoxx edition

CI INTEGRATIONThursday 15 November 12

Page 61: Code but now as we know it - Devoxx edition

https://github.com/nicksieger/ci_reporter

Junit processor for Ruby

Thursday 15 November 12

Page 62: Code but now as we know it - Devoxx edition

SYNTAX CHECKSCOMPILE CHECKS

UNIT TESTS

SMOKE TESTS

NO VM NEEDED

REAL VM

Thursday 15 November 12

Page 63: Code but now as we know it - Devoxx edition

SMOKE TESTING(ON REAL MACHINE)

Code Applied

CLEAN VM

STATE A STATE BCode Run Run TestsCreate VM

SNAPSHOT

Thursday 15 November 12

Page 64: Code but now as we know it - Devoxx edition

http://auxesis.github.com/cucumber-nagios/Thursday 15 November 12

Page 65: Code but now as we know it - Devoxx edition

RE-USABLE CUCUMBER STEPS

https://github.com/hedgehog/cukenhttps://github.com/cucumber/aruba

http://www.cucumber-chef.org/

Thursday 15 November 12

Page 66: Code but now as we know it - Devoxx edition

https://github.com/calavera/minitest-chef-handlerhttps://github.com/jedi4ever/puppet-assert

Validate “inside” the provision-run cycle

Thursday 15 November 12

Page 67: Code but now as we know it - Devoxx edition

VM CREATION IS EXPENSIVE

https://github.com/jedi4ever/saharahttps://github.com/t9md/vagrant-snap

Code Applied

CLEAN VM

STATE A STATE BCode Run Run TestsCreate VM

SNAPSHOT

ROLLBACK

Thursday 15 November 12

Page 68: Code but now as we know it - Devoxx edition

https://github.com/rtyler/vagrant-pluginThursday 15 November 12

Page 69: Code but now as we know it - Devoxx edition

https://travis-ci.org/

Uses vagrant & veewee

Thursday 15 November 12

Page 70: Code but now as we know it - Devoxx edition

https://github.com/tknerr/bills-kitchen

Windows

Thursday 15 November 12

Page 71: Code but now as we know it - Devoxx edition

TARGETED TESTINGIMPACT OF CHANGE

https://github.com/jedi4ever/puppet-cichttps://github.com/jonlives/knife-preflight

ROLE1

ROLE2

ROLEN

MODULEA

MODULEB

MODULEC

MODULE...

Real VM testingis expensive

Only test what’s needed

Thursday 15 November 12

Page 72: Code but now as we know it - Devoxx edition

PERFORMANCE/METRICS

Thursday 15 November 12

Page 73: Code but now as we know it - Devoxx edition

https://github.com/rodjek/puppet-profilerThursday 15 November 12

Page 74: Code but now as we know it - Devoxx edition

https://github.com/joemiller/puppet-graphite_eventhttps://github.com/imeyer/chef-handler-graphite

https://github.com/krux/puppet-module-graphite-report

execution timenumber of classes

Thursday 15 November 12

Page 75: Code but now as we know it - Devoxx edition

Infrastructure as Code Patrick Deboishttp://www.tumblr.com/tagged/star-trek-quotes

Thursday 15 November 12

Page 76: Code but now as we know it - Devoxx edition

Thursday 15 November 12

Page 77: Code but now as we know it - Devoxx edition

THANKYOU!

Thursday 15 November 12

Page 78: Code but now as we know it - Devoxx edition

QUESTIONS?

Thursday 15 November 12

Page 79: Code but now as we know it - Devoxx edition

http://foodfightshow.org/

Thursday 15 November 12

Page 80: Code but now as we know it - Devoxx edition

Thursday 15 November 12

Page 81: Code but now as we know it - Devoxx edition

Thursday 15 November 12

Page 82: Code but now as we know it - Devoxx edition

http://wiki.opscode.com/display/chef/Whyrun+TestingThursday 15 November 12

Page 83: Code but now as we know it - Devoxx edition

https://github.com/lak/puppet-memcachedThursday 15 November 12

Page 84: Code but now as we know it - Devoxx edition

https://github.com/lak/puppet-static-compilerThursday 15 November 12

Page 86: Code but now as we know it - Devoxx edition

AUDITING

http://www.normation.com/en/solutions/rudderhttp://www.fusioninventory.org/

Thursday 15 November 12

Page 87: Code but now as we know it - Devoxx edition

http://comodit.github.com/synapse-agent/Thursday 15 November 12

Page 88: Code but now as we know it - Devoxx edition

http://saltstack.org/Thursday 15 November 12

Page 89: Code but now as we know it - Devoxx edition

https://github.com/tobami/littlechefThursday 15 November 12

Page 90: Code but now as we know it - Devoxx edition

https://github.com/dwt/vagrant-hostsThursday 15 November 12

Page 91: Code but now as we know it - Devoxx edition

https://github.com/opscode/omnibusThursday 15 November 12

Page 92: Code but now as we know it - Devoxx edition

https://github.com/puppetlabs/puppet-module-toolThursday 15 November 12

Page 95: Code but now as we know it - Devoxx edition

VENDORING

Thursday 15 November 12

Page 96: Code but now as we know it - Devoxx edition

https://github.com/railsmachine/rumpThursday 15 November 12

Page 98: Code but now as we know it - Devoxx edition

http://rundeck.org/Thursday 15 November 12

Page 99: Code but now as we know it - Devoxx edition

http://www.sonian.com/cloud-monitoring-sensu/Thursday 15 November 12

Page 100: Code but now as we know it - Devoxx edition

http://docs.puppetlabs.com/guides/parameterized_classes.htmlThursday 15 November 12

Page 101: Code but now as we know it - Devoxx edition

https://github.com/rerun/rerunThursday 15 November 12

Page 102: Code but now as we know it - Devoxx edition

AUTHENTICATION

Thursday 15 November 12

Page 103: Code but now as we know it - Devoxx edition

DASHBOARDS

Thursday 15 November 12

Page 104: Code but now as we know it - Devoxx edition

http://puppetlabs.com/puppet/related-projects/dashboard/Thursday 15 November 12

Page 106: Code but now as we know it - Devoxx edition

http://www.opscode.com/hosted-chef/Thursday 15 November 12

Page 107: Code but now as we know it - Devoxx edition

http://theforeman.org/Thursday 15 November 12

Page 108: Code but now as we know it - Devoxx edition

https://github.com/chapmanb/cloudbiolinuxThursday 15 November 12

Page 109: Code but now as we know it - Devoxx edition

https://github.com/aetherical/nimblestratusThursday 15 November 12

Page 110: Code but now as we know it - Devoxx edition

https://github.com/fiddyspence/puppet-mconotify

Thursday 15 November 12

Page 111: Code but now as we know it - Devoxx edition

Thursday 15 November 12