Virtualize and automate your development environment for fun and profit

107
Virtualize and automate your development environment for fun and profit Andreas Heim - May 23 2011 – Roots Conference, Bergen

Transcript of Virtualize and automate your development environment for fun and profit

Page 1: Virtualize and automate your development environment for fun and profit

Virtualize and automate your development environment for fun and profit

Andreas Heim - May 23 2011 – Roots Conference, Bergen

Page 2: Virtualize and automate your development environment for fun and profit

Vagrant

Virtualize and automate your development environment for fun and profit!

Andreas Heim - BEKK Consulting@heim

Page 3: Virtualize and automate your development environment for fun and profit

What defines a good development environment?

Page 4: Virtualize and automate your development environment for fun and profit

What defines a good development environment?

• Identical to production

Page 5: Virtualize and automate your development environment for fun and profit

What defines a good development environment?

• Identical to production

• Identical for all developers

Page 6: Virtualize and automate your development environment for fun and profit

What defines a good development environment?

• Identical to production

• Identical for all developers

• Independent of other systems

Page 7: Virtualize and automate your development environment for fun and profit

What defines a good development environment?

• Identical to production

• Identical for all developers

• Independent of other systems

• You should be able to work on a plane

Page 8: Virtualize and automate your development environment for fun and profit

Not this plane

Page 9: Virtualize and automate your development environment for fun and profit

Not this plane

(it has wi-fi)

Page 10: Virtualize and automate your development environment for fun and profit

What defines a good development environment II

Page 11: Virtualize and automate your development environment for fun and profit

What defines a good development environment II

• Lucid

Page 12: Virtualize and automate your development environment for fun and profit

What defines a good development environment II

• Lucid

• Well documented

Page 13: Virtualize and automate your development environment for fun and profit

What defines a good development environment II

• Lucid

• Well documented

• Fast on-boarding of new team members

Page 14: Virtualize and automate your development environment for fun and profit

What defines a good development environment II

• Lucid

• Well documented

• Fast on-boarding of new team members

• Versioned

Page 15: Virtualize and automate your development environment for fun and profit

challengesteam members might develop on two different operating

systems

Page 16: Virtualize and automate your development environment for fun and profit

challengesteam members might develop on two different operating

systems

and deploy to a third

Page 17: Virtualize and automate your development environment for fun and profit

challengesdevelopers might have different versions of dependencies

Page 18: Virtualize and automate your development environment for fun and profit

challengesdevelopers might have different versions of dependencies

database

Page 19: Virtualize and automate your development environment for fun and profit

challengesdevelopers might have different versions of dependencies

database

build tools

Page 20: Virtualize and automate your development environment for fun and profit

challengesdevelopers might have different versions of dependencies

database

build toolsapp server

Page 21: Virtualize and automate your development environment for fun and profit

challengesdevelopers might not have taken the time to install

Page 22: Virtualize and automate your development environment for fun and profit

challengesdevelopers might not have taken the time to install

enterprise database

Page 23: Virtualize and automate your development environment for fun and profit

challengesdevelopers might not have taken the time to install

enterprise database

enterprise app server

Page 24: Virtualize and automate your development environment for fun and profit

challengesdevelopers might not have taken the time to install

enterprise database

enterprise app server

because normally “enterprise” means slow and complex

Page 25: Virtualize and automate your development environment for fun and profit

contamination

if you got multiple applications accessing the same database or central service...

Page 26: Virtualize and automate your development environment for fun and profit

contamination

how quick can you reset your development environment?

if you got multiple applications accessing the same database or central service...

Page 27: Virtualize and automate your development environment for fun and profit

contamination

how quick can you reset your development environment?

if you got multiple applications accessing the same database or central service...

can one application contaminate the data of the other?

Page 28: Virtualize and automate your development environment for fun and profit

automate and virtualize

Page 29: Virtualize and automate your development environment for fun and profit

distributea virtual machine that contains all of the projects dependencies

Page 30: Virtualize and automate your development environment for fun and profit

distributea virtual machine that contains all of the projects dependencies

app server, database, stubbed external services

Page 31: Virtualize and automate your development environment for fun and profit

so, what are we actually talking about?

Page 32: Virtualize and automate your development environment for fun and profit

developer 1

some db v. 1.02app server. v. 9.2.1

apple java 1.6

developer 2

OS: Windows 7

app server. v. 9.3.1

sun java 1.6

production machine

“enterprise db”“scalable app server”

openjdk 1.5

OS: snow leopard

some db v 1.03

OS: Ubuntu

Page 33: Virtualize and automate your development environment for fun and profit

virtual linux macine

enterprise dbenterprise app servercorrect java version

script the installation of this machine

Page 34: Virtualize and automate your development environment for fun and profit

virtualized environment inside your machine

Page 35: Virtualize and automate your development environment for fun and profit

virtualized environment inside your machine

develop using your existing tools

Page 36: Virtualize and automate your development environment for fun and profit

virtualized environment inside your machine

develop using your existing tools

run your code on the virtual machine

Page 37: Virtualize and automate your development environment for fun and profit

developer 1 developer 2

Virtual machine

Virtual machine

shared folder

shared folder

editor editor

production machine

OS: Ubuntuscript the setup of this machine

Page 38: Virtualize and automate your development environment for fun and profit

vagrantvagrantup.com

Page 39: Virtualize and automate your development environment for fun and profit

built on top ofruby application(ruby power)

Page 40: Virtualize and automate your development environment for fun and profit

built on top of• sun virtualbox

ruby application(ruby power)

Page 41: Virtualize and automate your development environment for fun and profit

built on top of• sun virtualbox

• chef

ruby application(ruby power)

Page 42: Virtualize and automate your development environment for fun and profit

built on top of• sun virtualbox

• chef

• puppet

ruby application(ruby power)

Page 43: Virtualize and automate your development environment for fun and profit

vagrant lets you

Page 44: Virtualize and automate your development environment for fun and profit

automate creationand provisioning

of virtual machines

vagrant lets you

Page 45: Virtualize and automate your development environment for fun and profit

replicate

Page 46: Virtualize and automate your development environment for fun and profit

replicate

rebuildand

Page 47: Virtualize and automate your development environment for fun and profit

replicate

rebuildand

instantly!

Page 48: Virtualize and automate your development environment for fun and profit

built on top of rakeeasy to extend

Page 49: Virtualize and automate your development environment for fun and profit

create your virtual machine with $ vagrant up

Page 50: Virtualize and automate your development environment for fun and profit

create your virtual machine with $ vagrant up

shut it down with$ vagrant halt

Page 51: Virtualize and automate your development environment for fun and profit

create your virtual machine with $ vagrant up

shut it down with$ vagrant halt

destroy it with$ vagrant destroy

Page 52: Virtualize and automate your development environment for fun and profit

and rebuild it instantly with$ vagrant up

Page 53: Virtualize and automate your development environment for fun and profit

easy configuration

Vagrant::Config.run do |config|  config.vm.box = "base"  config.vm.box_url = "http://files.vagrantup.com/lucid32.box"end

lots of boxes on http://vagrantbox.es

Page 54: Virtualize and automate your development environment for fun and profit

port forwarding

Vagrant::Config.run do |config|  config.vm.forward_port "http", 80, 8080end

forwards port 8080 on the host os to port 80 on the vm

Page 55: Virtualize and automate your development environment for fun and profit

multiple vms

Vagrant::Config.run do |config| config.vm.define :web do |web_config| web_config.vm.box = "web" web_config.vm.forward_port("http", 80, 8080) end

config.vm.define :db do |db_config| db_config.vm.box = "db" db_config.vm.forward_port("db", 3306, 3306) endend

Page 56: Virtualize and automate your development environment for fun and profit

provisioning

Page 57: Virtualize and automate your development environment for fun and profit

provisioning

the act of preparing and equipping a VM to run your application

Page 58: Virtualize and automate your development environment for fun and profit

provisioning

the act of preparing and equipping a VM to run your application

in practice, installing software and configuring the machine

Page 59: Virtualize and automate your development environment for fun and profit

alternatives

chef

puppet

Page 60: Virtualize and automate your development environment for fun and profit

alternatives

chef

puppet

pure ruby, flexible, big ecosystem

Page 61: Virtualize and automate your development environment for fun and profit

alternatives

chef

puppet

pure ruby, flexible, big ecosystem

complicated, lots of files

Page 62: Virtualize and automate your development environment for fun and profit

alternatives

chef

puppet

pure ruby, flexible, big ecosystem

complicated, lots of files

supported by google, flexible

Page 63: Virtualize and automate your development environment for fun and profit

alternatives

chef

puppet

pure ruby, flexible, big ecosystem

complicated, lots of files

supported by google, flexible

hard to get started

Page 64: Virtualize and automate your development environment for fun and profit

or use sprinkle, for simplicity

Page 65: Virtualize and automate your development environment for fun and profit

or use sprinkle, for simplicity

sprinkle is a really nice ruby dslgithub.com/crafterm/sprinkle

Page 66: Virtualize and automate your development environment for fun and profit

or use sprinkle, for simplicity

sprinkle is a really nice ruby dslgithub.com/crafterm/sprinkle

package :git, :provides => :scm do  description 'Git Distributed Version Control'  apt "git-core"   verify do    has_executable "git"  endend

find this code on http://github.com/heim/vagrant-java-example

Page 67: Virtualize and automate your development environment for fun and profit

and roll your own provisioner

class SprinkleProvisioner < Vagrant::Provisioners::Base  def prepare      end

  def provision!    vm.ssh.execute do |ssh|     ssh.exec!('gem list | grep "i18n (0.5.0)" ;if [ $? == "1" ]; then sudo gem install i18n --version "0.5.0"; fi;')     ssh.exec!('gem list | grep "sprinkle (0.3.3)" ;if [ $? == "1" ]; then sudo gem install sprinkle --version "0.3.3"; fi;')     ssh.exec!("sudo sprinkle -v -c -s /vagrant/sprinkle/install.rb")    end  endend

find this code on http://github.com/heim/vagrant-java-example

Page 68: Virtualize and automate your development environment for fun and profit

config your provisioner for use with vagrant

Page 69: Virtualize and automate your development environment for fun and profit

config your provisioner for use with vagrant

Vagrant::Config.run do |config|  config.vm.provision SprinkleProvisionerend

Page 70: Virtualize and automate your development environment for fun and profit

config your provisioner for use with vagrant

Vagrant::Config.run do |config|  config.vm.provision SprinkleProvisionerend

Vagrant::Config.run do |config|  config.vm.provision :chef_soloend

Page 71: Virtualize and automate your development environment for fun and profit

config your provisioner for use with vagrant

Vagrant::Config.run do |config|  config.vm.provision SprinkleProvisionerend

Vagrant::Config.run do |config|  config.vm.provision :chef_soloend

Vagrant::Config.run do |config| config.vm.provision :shell, :path => "test.sh"end

Page 72: Virtualize and automate your development environment for fun and profit

but, why?

Page 73: Virtualize and automate your development environment for fun and profit

run code on production like environment

Page 74: Virtualize and automate your development environment for fun and profit

run code on production like environmentinstant feedback

Page 75: Virtualize and automate your development environment for fun and profit

run code on production like environment

catches bugs early

instant feedback

Page 76: Virtualize and automate your development environment for fun and profit

run code on production like environment

catches bugs early

even before they hit scm

instant feedback

Page 77: Virtualize and automate your development environment for fun and profit

or if your setup is complicated

Page 78: Virtualize and automate your development environment for fun and profit

or if your setup is complicateddo it quick

Page 79: Virtualize and automate your development environment for fun and profit

or if your setup is complicated

reset data quickly

do it quick

Page 80: Virtualize and automate your development environment for fun and profit

or if your setup is complicated

reset data quickly

everything in one package

do it quick

Page 81: Virtualize and automate your development environment for fun and profit

or if your setup is complicated

reset data quickly

everything in one package

do it quick

and you’re probably better off using sprinkle

Page 82: Virtualize and automate your development environment for fun and profit

for teams

Page 83: Virtualize and automate your development environment for fun and profit

for teams

identical environments

Page 84: Virtualize and automate your development environment for fun and profit

for teams

identical environments

single responsibility principle

Page 85: Virtualize and automate your development environment for fun and profit

for teams

identical environments

single responsibility principle

fast onboarding of new team members

Page 86: Virtualize and automate your development environment for fun and profit

for teams

identical environments

single responsibility principle

fast onboarding of new team members

increase in maintainability

Page 87: Virtualize and automate your development environment for fun and profit

for operations (or devops)

Page 88: Virtualize and automate your development environment for fun and profit

for operations (or devops)

test your provisioning scripts

Page 89: Virtualize and automate your development environment for fun and profit

for operations (or devops)

test your provisioning scripts

test your deploy scripts

Page 90: Virtualize and automate your development environment for fun and profit

for operations (or devops)

test your provisioning scripts

test your deploy scripts

test your clustering setup with multi-vms

Page 91: Virtualize and automate your development environment for fun and profit

for operations (or devops)

test your provisioning scripts

test your deploy scripts

test your clustering setup with multi-vms

test load balancing and fallback mechanisms

Page 92: Virtualize and automate your development environment for fun and profit

for operations (or devops)

test your provisioning scripts

test your deploy scripts

test your clustering setup with multi-vms

test load balancing and fallback mechanisms

(this can even be part of your CI-run)

Page 93: Virtualize and automate your development environment for fun and profit

use vagrant if you

Page 94: Virtualize and automate your development environment for fun and profit

use vagrant if youdeploy to the cloud

Page 95: Virtualize and automate your development environment for fun and profit

use vagrant if youdeploy to the cloud

already use chef or puppet

Page 96: Virtualize and automate your development environment for fun and profit

use vagrant if youdeploy to the cloud

already use chef or puppet

have a large amount of dependencies, and a complicated environment setup

Page 97: Virtualize and automate your development environment for fun and profit
Page 98: Virtualize and automate your development environment for fun and profit

your development environment is documented

Page 99: Virtualize and automate your development environment for fun and profit

your development environment is documented

because it is declarative

Page 100: Virtualize and automate your development environment for fun and profit

your development environment is documented

because it is declarative

and it is in the source repository

Page 101: Virtualize and automate your development environment for fun and profit

your development environment is documented

because it is declarative

and it is in the source repository

it is easy to replicate

Page 102: Virtualize and automate your development environment for fun and profit

your development environment is documented

because it is declarative

and it is in the source repository

it is easy to replicate

because its automated

Page 103: Virtualize and automate your development environment for fun and profit

your development environment is documented

because it is declarative

and it is in the source repository

it is easy to replicate

because its automated

it is independent of other systems

Page 104: Virtualize and automate your development environment for fun and profit

your development environment is documented

because it is declarative

and it is in the source repository

it is easy to replicate

because its automated

it is independent of other systems

because its virtualized

Page 105: Virtualize and automate your development environment for fun and profit

thanks!

spkr8.com/heim@heim

Page 107: Virtualize and automate your development environment for fun and profit

BEKK CONSULTING ASSKUR 39, VIPPETANGEN. P.O. BOX 134 SENTRUM, 0102 OSLO, NORWAY. WWW.BEKK.NO

ANDREAS HEIMCONSULTANT+47 959 39 833

[email protected]