Virtualize and automate your developmentenvironment for fun and profitAndreas Heim - May 23 2011 – Roots Conference, Bergen
VagrantVirtualize and automate your development      environment for fun and profit!          Andreas Heim - BEKK Consultin...
What defines a gooddevelopment environment?
What defines a gooddevelopment environment?• Identical to production
What defines a gooddevelopment environment?• Identical to production• Identical for all developers
What defines a gooddevelopment environment?• Identical to production• Identical for all developers• Independent of other sy...
What defines a gooddevelopment environment?• Identical to production• Identical for all developers• Independent of other sy...
Not this plane
Not this plane    (it has wi-fi)
What defines a gooddevelopment environment II
What defines a gooddevelopment environment II• Lucid
What defines a gooddevelopment environment II• Lucid• Well documented
What defines a gooddevelopment environment II• Lucid• Well documented• Fast on-boarding of new team members
What defines a gooddevelopment environment II• Lucid• Well documented• Fast on-boarding of new team members• Versioned
challengesteam members might develop on two different operating                     systems
challengesteam members might develop on two different operating                     systems                  and deploy to...
challengesdevelopers might have different versions of dependencies
challengesdevelopers might have different versions of dependencies                database
challengesdevelopers might have different versions of dependencies                database                     build tools
challengesdevelopers might have different versions of dependencies                database                     build tools...
challengesdevelopers might not have taken the time to install
challengesdevelopers might not have taken the time to install        enterprise database
challengesdevelopers might not have taken the time to install        enterprise database                 enterprise app se...
challenges  developers might not have taken the time to install          enterprise database                   enterprise ...
contaminationif you got multiple applications accessing the same            database or central service...
contamination if you got multiple applications accessing the same             database or central service...how quick can ...
contamination if you got multiple applications accessing the same             database or central service...how quick can ...
automate and virtualize
distributevirtual machine that contains all of the projects dependencies
distributevirtual machine that contains all of the projects dependencies     app server, database, stubbed external services
so, what are we actually talking about?
developer 1                          developer 2OS: snow leopard                      OS: Windows 7some db v. 1.02        ...
script the installation of this machinevirtual linux macine    enterprise dbenterprise app servercorrect java version
virtualized environment inside your machine
virtualized environment inside your machine         develop using your existing tools
virtualized environment inside your machine         develop using your existing tools           run your code on the virtu...
developer 1                    developer 2           editor                          editor Virtual   shared              ...
vagrant   vagrantup.com
ruby application(ruby power)          built on top of
ruby application(ruby power)          built on top of • sun virtualbox
ruby application(ruby power)          built on top of • sun virtualbox • chef
ruby application(ruby power)          built on top of • sun virtualbox • chef • puppet
vagrant lets you
vagrant lets you      automate creation       and provisioning      of virtual machines
replicate
replicate       and             rebuild
replicate       and             rebuild              instantly!
built on top of rake      easy to extend
create your virtual machine with         $ vagrant up
create your virtual machine with         $ vagrant up       shut it down with        $ vagrant halt
create your virtual machine with         $ vagrant up       shut it down with        $ vagrant halt        destroy it with...
and rebuild it instantly with      $ vagrant up
easy configuration   Vagrant::Config.run do |config|     config.vm.box = "base"     config.vm.box_url = "http://files.vagra...
port forwarding    Vagrant::Config.run do |config|      config.vm.forward_port "http", 80, 8080    endforwards port 8080 o...
multiple vmsVagrant::Config.run do |config|  config.vm.define :web do |web_config|    web_config.vm.box = "web"    web_con...
provisioning
provisioningthe act of preparing and equipping a VM to run                your application
provisioningthe act of preparing and equipping a VM to run                your application  in practice, installing softwa...
alternatives chefpuppet
alternatives               pure ruby, flexible, big ecosystem chefpuppet
alternatives               pure ruby, flexible, big ecosystem chef               complicated, lots of filespuppet
alternatives               pure ruby, flexible, big ecosystem chef               complicated, lots of files          support...
alternatives               pure ruby, flexible, big ecosystem chef               complicated, lots of files          support...
or use sprinkle, for simplicity
or use sprinkle, for simplicity   sprinkle is a really nice ruby dsl                                    github.com/crafter...
or use sprinkle, for simplicity    sprinkle is a really nice ruby dsl                                            github.co...
and roll your own provisionerclass SprinkleProvisioner < Vagrant::Provisioners::Base  def prepare      end  def provision!...
config your provisioner for use with vagrant
config your provisioner for use with vagrant   Vagrant::Config.run do |config|     config.vm.provision SprinkleProvisioner ...
config your provisioner for use with vagrant   Vagrant::Config.run do |config|     config.vm.provision SprinkleProvisioner ...
config your provisioner for use with vagrant   Vagrant::Config.run do |config|     config.vm.provision SprinkleProvisioner ...
but, why?
run code on production like environment
run code on production like environment    instant feedback
run code on production like environment    instant feedback        catches bugs early
run code on production like environment    instant feedback        catches bugs early            even before they hit scm
or if your setup is complicated
or if your setup is complicated  do it quick
or if your setup is complicated  do it quick    reset data quickly
or if your setup is complicated  do it quick    reset data quickly      everything in one package
or if your setup is complicated   do it quick     reset data quickly       everything in one packageand you’re probably be...
for teams
for teams  identical environments
for teams  identical environments     single responsibility principle
for teams  identical environments     single responsibility principle      fast onboarding of new team members
for teams  identical environments     single responsibility principle      fast onboarding of new team members            ...
for operations   (or devops)
for operations          (or devops) test your provisioning scripts
for operations          (or devops) test your provisioning scripts   test your deploy scripts
for operations          (or devops) test your provisioning scripts   test your deploy scripts     test your clustering set...
for operations          (or devops) test your provisioning scripts   test your deploy scripts     test your clustering set...
for operations          (or devops) test your provisioning scripts   test your deploy scripts     test your clustering set...
use vagrant if you
use vagrant if you deploy to the cloud
use vagrant if you deploy to the cloud    already use chef or puppet
use vagrant if you  deploy to the cloud     already use chef or puppet have a large amount of dependencies, and a complica...
your development environment is documented
your development environment is documented    because it is declarative
your development environment is documented    because it is declarative       and it is in the source repository
your development environment is documented     because it is declarative         and it is in the source repositoryit is e...
your development environment is documented     because it is declarative         and it is in the source repositoryit is e...
your development environment is documented     because it is declarative         and it is in the source repositoryit is e...
your development environment is documented     because it is declarative         and it is in the source repositoryit is e...
thanks!spkr8.com/heim   @heim
resources:http://vagrantup.comhttps://github.com/heim/vagrant-java-examplehttps://github.com/crafterm/sprinklehttp://vagra...
ANDREAS HEIM                          CONSULTANT                          +47 959 39 833                      andreas.heim...
Virtualize and automate your development environment for fun and profit
Upcoming SlideShare
Loading in …5
×

Virtualize and automate your development environment for fun and profit

3,678 views

Published on

Published in: Technology
0 Comments
6 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,678
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
46
Comments
0
Likes
6
Embeds 0
No embeds

No notes for slide

Virtualize and automate your development environment for fun and profit

  1. 1. Virtualize and automate your developmentenvironment for fun and profitAndreas Heim - May 23 2011 – Roots Conference, Bergen
  2. 2. VagrantVirtualize and automate your development environment for fun and profit! Andreas Heim - BEKK Consulting @heim
  3. 3. What defines a gooddevelopment environment?
  4. 4. What defines a gooddevelopment environment?• Identical to production
  5. 5. What defines a gooddevelopment environment?• Identical to production• Identical for all developers
  6. 6. What defines a gooddevelopment environment?• Identical to production• Identical for all developers• Independent of other systems
  7. 7. What defines a gooddevelopment environment?• Identical to production• Identical for all developers• Independent of other systems• You should be able to work on a plane
  8. 8. Not this plane
  9. 9. Not this plane (it has wi-fi)
  10. 10. What defines a gooddevelopment environment II
  11. 11. What defines a gooddevelopment environment II• Lucid
  12. 12. What defines a gooddevelopment environment II• Lucid• Well documented
  13. 13. What defines a gooddevelopment environment II• Lucid• Well documented• Fast on-boarding of new team members
  14. 14. What defines a gooddevelopment environment II• Lucid• Well documented• Fast on-boarding of new team members• Versioned
  15. 15. challengesteam members might develop on two different operating systems
  16. 16. challengesteam members might develop on two different operating systems and deploy to a third
  17. 17. challengesdevelopers might have different versions of dependencies
  18. 18. challengesdevelopers might have different versions of dependencies database
  19. 19. challengesdevelopers might have different versions of dependencies database build tools
  20. 20. challengesdevelopers might have different versions of dependencies database build tools app server
  21. 21. challengesdevelopers might not have taken the time to install
  22. 22. challengesdevelopers might not have taken the time to install enterprise database
  23. 23. challengesdevelopers might not have taken the time to install enterprise database enterprise app server
  24. 24. challenges developers might not have taken the time to install enterprise database enterprise app serverbecause normally “enterprise” means slow and complex
  25. 25. contaminationif you got multiple applications accessing the same database or central service...
  26. 26. contamination if you got multiple applications accessing the same database or central service...how quick can you reset your development environment?
  27. 27. contamination if you got multiple applications accessing the same database or central service...how quick can you reset your development environment? can one application contaminate the data of the other?
  28. 28. automate and virtualize
  29. 29. distributevirtual machine that contains all of the projects dependencies
  30. 30. distributevirtual machine that contains all of the projects dependencies app server, database, stubbed external services
  31. 31. so, what are we actually talking about?
  32. 32. developer 1 developer 2OS: snow leopard OS: Windows 7some db v. 1.02 some db v 1.03app server. v. 9.2.1 app server. v. 9.3.1 apple java 1.6 sun java 1.6 production machine OS: Ubuntu “enterprise db” “scalable app server” openjdk 1.5
  33. 33. script the installation of this machinevirtual linux macine enterprise dbenterprise app servercorrect java version
  34. 34. virtualized environment inside your machine
  35. 35. virtualized environment inside your machine develop using your existing tools
  36. 36. virtualized environment inside your machine develop using your existing tools run your code on the virtual machine
  37. 37. developer 1 developer 2 editor editor Virtual shared Virtual sharedmachine folder machine folder production machinescript the setup of this OS: Ubuntu machine
  38. 38. vagrant vagrantup.com
  39. 39. ruby application(ruby power) built on top of
  40. 40. ruby application(ruby power) built on top of • sun virtualbox
  41. 41. ruby application(ruby power) built on top of • sun virtualbox • chef
  42. 42. ruby application(ruby power) built on top of • sun virtualbox • chef • puppet
  43. 43. vagrant lets you
  44. 44. vagrant lets you automate creation and provisioning of virtual machines
  45. 45. replicate
  46. 46. replicate and rebuild
  47. 47. replicate and rebuild instantly!
  48. 48. built on top of rake easy to extend
  49. 49. create your virtual machine with $ vagrant up
  50. 50. create your virtual machine with $ vagrant up shut it down with $ vagrant halt
  51. 51. create your virtual machine with $ vagrant up shut it down with $ vagrant halt destroy it with $ vagrant destroy
  52. 52. and rebuild it instantly with $ vagrant up
  53. 53. 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
  54. 54. port forwarding Vagrant::Config.run do |config|   config.vm.forward_port "http", 80, 8080 endforwards port 8080 on the host os to port 80 on the vm
  55. 55. multiple vmsVagrant::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
  56. 56. provisioning
  57. 57. provisioningthe act of preparing and equipping a VM to run your application
  58. 58. provisioningthe act of preparing and equipping a VM to run your application in practice, installing software and configuring the machine
  59. 59. alternatives chefpuppet
  60. 60. alternatives pure ruby, flexible, big ecosystem chefpuppet
  61. 61. alternatives pure ruby, flexible, big ecosystem chef complicated, lots of filespuppet
  62. 62. alternatives pure ruby, flexible, big ecosystem chef complicated, lots of files supported by google, flexiblepuppet
  63. 63. alternatives pure ruby, flexible, big ecosystem chef complicated, lots of files supported by google, flexiblepuppet hard to get started
  64. 64. or use sprinkle, for simplicity
  65. 65. or use sprinkle, for simplicity sprinkle is a really nice ruby dsl github.com/crafterm/sprinkle
  66. 66. or use sprinkle, for simplicity sprinkle is a really nice ruby dsl github.com/crafterm/sprinklepackage :git, :provides => :scm do  description Git Distributed Version Control  apt "git-core"   verify do    has_executable "git"  endendfind this code on http://github.com/heim/vagrant-java-example
  67. 67. and roll your own provisionerclass 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
  68. 68. config your provisioner for use with vagrant
  69. 69. config your provisioner for use with vagrant Vagrant::Config.run do |config|   config.vm.provision SprinkleProvisioner end
  70. 70. config your provisioner for use with vagrant Vagrant::Config.run do |config|   config.vm.provision SprinkleProvisioner end Vagrant::Config.run do |config|   config.vm.provision :chef_solo end
  71. 71. config your provisioner for use with vagrant Vagrant::Config.run do |config|   config.vm.provision SprinkleProvisioner end Vagrant::Config.run do |config|   config.vm.provision :chef_solo end Vagrant::Config.run do |config| config.vm.provision :shell, :path => "test.sh" end
  72. 72. but, why?
  73. 73. run code on production like environment
  74. 74. run code on production like environment instant feedback
  75. 75. run code on production like environment instant feedback catches bugs early
  76. 76. run code on production like environment instant feedback catches bugs early even before they hit scm
  77. 77. or if your setup is complicated
  78. 78. or if your setup is complicated do it quick
  79. 79. or if your setup is complicated do it quick reset data quickly
  80. 80. or if your setup is complicated do it quick reset data quickly everything in one package
  81. 81. or if your setup is complicated do it quick reset data quickly everything in one packageand you’re probably better off using sprinkle
  82. 82. for teams
  83. 83. for teams identical environments
  84. 84. for teams identical environments single responsibility principle
  85. 85. for teams identical environments single responsibility principle fast onboarding of new team members
  86. 86. for teams identical environments single responsibility principle fast onboarding of new team members increase in maintainability
  87. 87. for operations (or devops)
  88. 88. for operations (or devops) test your provisioning scripts
  89. 89. for operations (or devops) test your provisioning scripts test your deploy scripts
  90. 90. for operations (or devops) test your provisioning scripts test your deploy scripts test your clustering setup with multi-vms
  91. 91. 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
  92. 92. 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)
  93. 93. use vagrant if you
  94. 94. use vagrant if you deploy to the cloud
  95. 95. use vagrant if you deploy to the cloud already use chef or puppet
  96. 96. use vagrant if you deploy to the cloud already use chef or puppet have a large amount of dependencies, and a complicated environment setup
  97. 97. your development environment is documented
  98. 98. your development environment is documented because it is declarative
  99. 99. your development environment is documented because it is declarative and it is in the source repository
  100. 100. your development environment is documented because it is declarative and it is in the source repositoryit is easy to replicate
  101. 101. your development environment is documented because it is declarative and it is in the source repositoryit is easy to replicate because its automated
  102. 102. your development environment is documented because it is declarative and it is in the source repositoryit is easy to replicate because its automatedit is independent of other systems
  103. 103. your development environment is documented because it is declarative and it is in the source repositoryit is easy to replicate because its automatedit is independent of other systems because its virtualized
  104. 104. thanks!spkr8.com/heim @heim
  105. 105. resources:http://vagrantup.comhttps://github.com/heim/vagrant-java-examplehttps://github.com/crafterm/sprinklehttp://vagrantbox.es
  106. 106. ANDREAS HEIM CONSULTANT +47 959 39 833 andreas.heim@bekk.no BEKK CONSULTING ASSKUR 39, VIPPETANGEN. P.O. BOX 134 SENTRUM, 0102 OSLO, NORWAY. WWW.BEKK.NO

×