102
Infrastructure as Code Patrick Debois http://www.tumblr.com/tagged/star-trek-quotes Wednesday 17 October 12

Code but not as we know it - Infrastructure as code

Embed Size (px)

DESCRIPTION

An overview on the similarities between ordinary code/practices vs infrastructure as code. Expect a lot of tools, and links to further exploration.

Citation preview

Page 1: Code but not as we know it - Infrastructure as code

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

Wednesday 17 October 12

Page 2: Code but not as we know it - Infrastructure as code

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

Wednesday 17 October 12

Page 3: Code but not as we know it - Infrastructure as code

CONFIGURATION MANAGEMENT SYSTEMS

http://ansible.cc/

http://opscode.com/chef/

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

Wednesday 17 October 12

Page 4: Code but not as we know it - Infrastructure as code

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

Chef & Puppet focusedbased on my experience

Wednesday 17 October 12

Page 5: Code but not as we know it - Infrastructure as code

GIVE ME THE CODE:“LANGUAGE”

Wednesday 17 October 12

Page 6: Code but not as we know it - Infrastructure as code

Puppet Chef

class myapache {

package “apache2”

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

}

package “apache2”

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

EXAMPLE SYNTAX

Wednesday 17 October 12

Page 7: Code but not as we know it - Infrastructure as code

TERMINOLOGY

Java Puppet Chef

*.javamanifests

*.pprecipes

*.rb

package module cookbook

Wednesday 17 October 12

Page 8: Code but not as we know it - Infrastructure as code

TERMINOLOGY (2)

Java Puppet Chef

singletonparametrized

classesrecipes with attributes

classdefines, classes

definitions, libraries

Wednesday 17 October 12

Page 9: Code but not as we know it - Infrastructure as code

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

Wednesday 17 October 12

Page 10: Code but not as we know it - Infrastructure as code

LOOPING CONSTRUCTS

Puppet Chef

pass array of elementserb template for loops

create_resource (:type, hash)

do while , repeat etc. available through

native ruby

Wednesday 17 October 12

Page 11: Code but not as we know it - Infrastructure as code

VARIABLES

Puppet Chef

special syntax$bla = “aa”

string interpolation$bla_string = “${bla}”

native rubybla = “aa”

string interpolationbla_string = #{bla}

Wednesday 17 October 12

Page 12: Code but not as we know it - Infrastructure as code

SINGLE CLASSINHERITANCE

Puppet Chef

override via ‘module path’

override via ‘cookbook’ path

+> operator “cookbook” attribute

Wednesday 17 October 12

Page 13: Code but not as we know it - Infrastructure as code

Puppet Module Chef Cookbook

files/lib/

README.rdocmanifests/templates/

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

PROJECT STRUCTURE

Wednesday 17 October 12

Page 14: Code but not as we know it - Infrastructure as code

EXECUTION MODEL

Puppet Chef

Compile catalog(directed graph

model)Then Execute

Top Down execution

Wednesday 17 October 12

Page 15: Code but not as we know it - Infrastructure as code

CODE EDITOR

Wednesday 17 October 12

Page 16: Code but not as we know it - Infrastructure as code

VIM SYNTAX HIGHLIGHTIING

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

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

Wednesday 17 October 12

Page 17: Code but not as we know it - Infrastructure as code

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

GEPPETTO - ECLIPSE IDE

Wednesday 17 October 12

Page 18: Code but not as we know it - Infrastructure as code

WYSIWYG CODING

REACTOR8

http://beta.r8network.com/Wednesday 17 October 12

Page 19: Code but not as we know it - Infrastructure as code

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

Wednesday 17 October 12

Page 20: Code but not as we know it - Infrastructure as code

CODE GENERATION

Wednesday 17 October 12

Page 21: Code but not as we know it - Infrastructure as code

REVERSE ENGINEERING

https://github.com/devstructure/blueprint

Existing Server -> Manifest/Recipes

Wednesday 17 October 12

Page 22: Code but not as we know it - Infrastructure as code

DSL ON TOP OF PUPPET~GRAILS

https://github.com/jnewland/shadow_puppetNote: Not vastly used

Wednesday 17 October 12

Page 23: Code but not as we know it - Infrastructure as code

CODING STYLE

Wednesday 17 October 12

Page 24: Code but not as we know it - Infrastructure as code

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

Wednesday 17 October 12

Page 26: Code but not as we know it - Infrastructure as code

CODE VS CONFIG(THINK “PROFILES”)

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

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

Wednesday 17 October 12

Page 27: Code but not as we know it - Infrastructure as code

“STOP THE FORK(ING)”

https://github.com/jedi4ever/stop-the-forkWednesday 17 October 12

Page 28: Code but not as we know it - Infrastructure as code

PRE-COMMIT CHECKS

Wednesday 17 October 12

Page 29: Code but not as we know it - Infrastructure as code

DEPENDENCY MGMT

GitSubmodules

Subtree à la Pom File

Wednesday 17 October 12

Page 30: Code but not as we know it - Infrastructure as code

UPSTREAM REPOS

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

Wednesday 17 October 12

Page 31: Code but not as we know it - Infrastructure as code

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"

Wednesday 17 October 12

Page 32: Code but not as we know it - Infrastructure as code

CHEF METADATA

Wednesday 17 October 12

Page 33: Code but not as we know it - Infrastructure as code

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

Puppet Dependency Graphs

Wednesday 17 October 12

Page 34: Code but not as we know it - Infrastructure as code

http://wham.cloudsmith.comWednesday 17 October 12

Page 35: Code but not as we know it - Infrastructure as code

DEBUGGING

Wednesday 17 October 12

Page 36: Code but not as we know it - Infrastructure as code

LOGGING WITH DIFFERENT LEVELS

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

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

Wednesday 17 October 12

Page 37: Code but not as we know it - Infrastructure as code

REPL - STYLE(READ EVAL PRINT)

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

Wednesday 17 October 12

Page 38: Code but not as we know it - Infrastructure as code

https://github.com/vimeo/simple-black-boxWednesday 17 October 12

Page 39: Code but not as we know it - Infrastructure as code

DEV ENVIRONMENT

Wednesday 17 October 12

Page 40: Code but not as we know it - Infrastructure as code

http://vagrantup.com/Virtualbox + (Fusion Soon)

https://github.com/jedi4ever/veewee/Virtualbox, Fusion, KVM,Parallels,

Wednesday 17 October 12

Page 41: Code but not as we know it - Infrastructure as code

https://github.com/rtyler/blimpy

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

Vagrant alike

EC2, KVM, FUSION, HOSTS, Vagrant

EC2

Wednesday 17 October 12

Page 42: Code but not as we know it - Infrastructure as code

UNIT TESTING

Wednesday 17 October 12

Page 43: Code but not as we know it - Infrastructure as code

https://github.com/nistude/cucumber-puppetWednesday 17 October 12

Page 44: Code but not as we know it - Infrastructure as code

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

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

Wednesday 17 October 12

Page 45: Code but not as we know it - Infrastructure as code

Wednesday 17 October 12

Page 46: Code but not as we know it - Infrastructure as code

MOCKING

Wednesday 17 October 12

Page 47: Code but not as we know it - Infrastructure as code

https://github.com/customink/fauxhaiWednesday 17 October 12

Page 48: Code but not as we know it - Infrastructure as code

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

Wednesday 17 October 12

Page 49: Code but not as we know it - Infrastructure as code

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

https://github.com/exceedhl/toft

Faster testing via LXC

EC2+LXC

Vagrant+LXCWednesday 17 October 12

Page 50: Code but not as we know it - Infrastructure as code

CI INTEGRATION

Wednesday 17 October 12

Page 51: Code but not as we know it - Infrastructure as code

https://github.com/nicksieger/ci_reporterWednesday 17 October 12

Page 52: Code but not as we know it - Infrastructure as code

https://github.com/rtyler/vagrant-pluginWednesday 17 October 12

Page 53: Code but not as we know it - Infrastructure as code

https://travis-ci.org/Wednesday 17 October 12

Page 54: Code but not as we know it - Infrastructure as code

CROSS OS-TESTING

https://github.com/opscode/test-kitchenhttps://github.com/opscode/bento

Wednesday 17 October 12

Page 55: Code but not as we know it - Infrastructure as code

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

Windows

Wednesday 17 October 12

Page 56: Code but not as we know it - Infrastructure as code

INTEGRATION TESTING(ON REAL MACHINE)

Wednesday 17 October 12

Page 57: Code but not as we know it - Infrastructure as code

http://auxesis.github.com/cucumber-nagios/Wednesday 17 October 12

Page 58: Code but not as we know it - Infrastructure as code

RE-USABLE CUCUMBER STEPS

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

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

Wednesday 17 October 12

Page 59: Code but not as we know it - Infrastructure as code

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

Validate “inside” the provision-run cycle

Wednesday 17 October 12

Page 60: Code but not as we know it - Infrastructure as code

PERFORMANCE/METRICS

Wednesday 17 October 12

Page 61: Code but not as we know it - Infrastructure as code

https://github.com/rodjek/puppet-profilerWednesday 17 October 12

Page 62: Code but not as we know it - Infrastructure as code

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

Wednesday 17 October 12

Page 63: Code but not as we know it - Infrastructure as code

TARGETED TESTINGIMPACT OF CHANGE

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

Wednesday 17 October 12

Page 64: Code but not as we know it - Infrastructure as code

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

Wednesday 17 October 12

Page 65: Code but not as we know it - Infrastructure as code

Wednesday 17 October 12

Page 66: Code but not as we know it - Infrastructure as code

http://foodfightshow.org/

Wednesday 17 October 12

Page 67: Code but not as we know it - Infrastructure as code

Wednesday 17 October 12

Page 68: Code but not as we know it - Infrastructure as code

http://wiki.opscode.com/display/chef/Whyrun+TestingWednesday 17 October 12

Page 69: Code but not as we know it - Infrastructure as code

https://github.com/tbatchelli/vmfestWednesday 17 October 12

Page 70: Code but not as we know it - Infrastructure as code

Wednesday 17 October 12

Page 71: Code but not as we know it - Infrastructure as code

CACHING - AMI, SNAPSHOTS

Wednesday 17 October 12

Page 72: Code but not as we know it - Infrastructure as code

https://github.com/lak/puppet-memcachedWednesday 17 October 12

Page 73: Code but not as we know it - Infrastructure as code

https://github.com/lak/puppet-static-compilerWednesday 17 October 12

Page 75: Code but not as we know it - Infrastructure as code

AUDITING

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

Wednesday 17 October 12

Page 76: Code but not as we know it - Infrastructure as code

http://comodit.github.com/synapse-agent/Wednesday 17 October 12

Page 77: Code but not as we know it - Infrastructure as code

http://saltstack.org/Wednesday 17 October 12

Page 78: Code but not as we know it - Infrastructure as code

https://github.com/tobami/littlechefWednesday 17 October 12

Page 79: Code but not as we know it - Infrastructure as code

https://github.com/dwt/vagrant-hostsWednesday 17 October 12

Page 80: Code but not as we know it - Infrastructure as code

https://github.com/opscode/omnibusWednesday 17 October 12

Page 81: Code but not as we know it - Infrastructure as code

https://github.com/puppetlabs/puppet-module-toolWednesday 17 October 12

Page 84: Code but not as we know it - Infrastructure as code

VENDORING

Wednesday 17 October 12

Page 85: Code but not as we know it - Infrastructure as code

https://github.com/railsmachine/rumpWednesday 17 October 12

Page 87: Code but not as we know it - Infrastructure as code

PLUGINS

Wednesday 17 October 12

Page 88: Code but not as we know it - Infrastructure as code

http://wiki.opscode.com/display/chef/Knife+PluginsWednesday 17 October 12

Page 90: Code but not as we know it - Infrastructure as code

TESTING

Wednesday 17 October 12

Page 91: Code but not as we know it - Infrastructure as code

http://rundeck.org/Wednesday 17 October 12

Page 92: Code but not as we know it - Infrastructure as code

http://www.sonian.com/cloud-monitoring-sensu/Wednesday 17 October 12

Page 93: Code but not as we know it - Infrastructure as code

http://docs.puppetlabs.com/guides/parameterized_classes.htmlWednesday 17 October 12

Page 94: Code but not as we know it - Infrastructure as code

INHERITANCE

Wednesday 17 October 12

Page 95: Code but not as we know it - Infrastructure as code

NAMESPACING

Wednesday 17 October 12

Page 96: Code but not as we know it - Infrastructure as code

https://github.com/rerun/rerunWednesday 17 October 12

Page 97: Code but not as we know it - Infrastructure as code

AUTHENTICATION

Wednesday 17 October 12

Page 98: Code but not as we know it - Infrastructure as code

DASHBOARDS

Wednesday 17 October 12

Page 99: Code but not as we know it - Infrastructure as code

http://puppetlabs.com/puppet/related-projects/dashboard/Wednesday 17 October 12

Page 101: Code but not as we know it - Infrastructure as code

http://www.opscode.com/hosted-chef/Wednesday 17 October 12

Page 102: Code but not as we know it - Infrastructure as code

http://theforeman.org/Wednesday 17 October 12