Code but not as we know it - Infrastructure as code

Preview:

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

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

Wednesday 17 October 12

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

CONFIGURATION MANAGEMENT SYSTEMS

http://ansible.cc/

http://opscode.com/chef/

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

Wednesday 17 October 12

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

Chef & Puppet focusedbased on my experience

Wednesday 17 October 12

GIVE ME THE CODE:“LANGUAGE”

Wednesday 17 October 12

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

TERMINOLOGY

Java Puppet Chef

*.javamanifests

*.pprecipes

*.rb

package module cookbook

Wednesday 17 October 12

TERMINOLOGY (2)

Java Puppet Chef

singletonparametrized

classesrecipes with attributes

classdefines, classes

definitions, libraries

Wednesday 17 October 12

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

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

VARIABLES

Puppet Chef

special syntax$bla = “aa”

string interpolation$bla_string = “${bla}”

native rubybla = “aa”

string interpolationbla_string = #{bla}

Wednesday 17 October 12

SINGLE CLASSINHERITANCE

Puppet Chef

override via ‘module path’

override via ‘cookbook’ path

+> operator “cookbook” attribute

Wednesday 17 October 12

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

EXECUTION MODEL

Puppet Chef

Compile catalog(directed graph

model)Then Execute

Top Down execution

Wednesday 17 October 12

CODE EDITOR

Wednesday 17 October 12

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

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

GEPPETTO - ECLIPSE IDE

Wednesday 17 October 12

WYSIWYG CODING

REACTOR8

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

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

Wednesday 17 October 12

CODE GENERATION

Wednesday 17 October 12

REVERSE ENGINEERING

https://github.com/devstructure/blueprint

Existing Server -> Manifest/Recipes

Wednesday 17 October 12

DSL ON TOP OF PUPPET~GRAILS

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

Wednesday 17 October 12

CODING STYLE

Wednesday 17 October 12

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

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

“STOP THE FORK(ING)”

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

PRE-COMMIT CHECKS

Wednesday 17 October 12

DEPENDENCY MGMT

GitSubmodules

Subtree à la Pom File

Wednesday 17 October 12

UPSTREAM REPOS

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

Wednesday 17 October 12

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

CHEF METADATA

Wednesday 17 October 12

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

Puppet Dependency Graphs

Wednesday 17 October 12

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

DEBUGGING

Wednesday 17 October 12

LOGGING WITH DIFFERENT LEVELS

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

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

Wednesday 17 October 12

REPL - STYLE(READ EVAL PRINT)

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

Wednesday 17 October 12

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

DEV ENVIRONMENT

Wednesday 17 October 12

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

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

Wednesday 17 October 12

https://github.com/rtyler/blimpy

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

Vagrant alike

EC2, KVM, FUSION, HOSTS, Vagrant

EC2

Wednesday 17 October 12

UNIT TESTING

Wednesday 17 October 12

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

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

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

Wednesday 17 October 12

Wednesday 17 October 12

MOCKING

Wednesday 17 October 12

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

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

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

https://github.com/exceedhl/toft

Faster testing via LXC

EC2+LXC

Vagrant+LXCWednesday 17 October 12

CI INTEGRATION

Wednesday 17 October 12

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

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

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

CROSS OS-TESTING

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

Wednesday 17 October 12

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

Windows

Wednesday 17 October 12

INTEGRATION TESTING(ON REAL MACHINE)

Wednesday 17 October 12

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

RE-USABLE CUCUMBER STEPS

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

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

Wednesday 17 October 12

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

Validate “inside” the provision-run cycle

Wednesday 17 October 12

PERFORMANCE/METRICS

Wednesday 17 October 12

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

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

TARGETED TESTINGIMPACT OF CHANGE

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

Wednesday 17 October 12

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

Wednesday 17 October 12

Wednesday 17 October 12

http://foodfightshow.org/

Wednesday 17 October 12

Wednesday 17 October 12

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

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

Wednesday 17 October 12

CACHING - AMI, SNAPSHOTS

Wednesday 17 October 12

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

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

AUDITING

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

Wednesday 17 October 12

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

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

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

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

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

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

VENDORING

Wednesday 17 October 12

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

PLUGINS

Wednesday 17 October 12

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

TESTING

Wednesday 17 October 12

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

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

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

INHERITANCE

Wednesday 17 October 12

NAMESPACING

Wednesday 17 October 12

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

AUTHENTICATION

Wednesday 17 October 12

DASHBOARDS

Wednesday 17 October 12

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

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

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

Recommended