Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Vagrant-Binding JUG Dortmund

1,782 views

Published on

  • Be the first to like this

Vagrant-Binding JUG Dortmund

  1. 1. Lightweight and reproducible environments withVagrant & Puppet & Java
  2. 2. About me•Hendrik Ebbers•Lead of development at SIC GmbH in Dortmund, Germany•Lead of JUG Dortmund•DataFX, JFXtras Contributor @hendrikEbbers www.guigarage.com hendrik.ebbers@web.de
  3. 3. Content•Virtualization•Vagrant•Puppet•Java Vagrant-Binding API
  4. 4. Virtualization
  5. 5. Evolution of VMs achines Vir tual M VM tempMachines lates automated VM creation
  6. 6. Antipattern by example
  7. 7. By only u sing VMs we canrebuild any customersystem
  8. 8. For ea ch new customerthe b est matching VM iscopied. S o no initial setupis needed!
  9. 9. Why not deploy all linux64bit customerinstallat ions on one serverVM?
  10. 10. Because we copy the VMs onour Laptop s when we travelto the Custo mer. And we onlyneed the system for oneCustomer then.
  11. 11. So you have a virtualized rServe r for every Custome rkwhe re all developers woon?
  12. 12. No only one de veloper works on sone VM. If a developer start eworkin g for a customer hsimp ly copies the VM ofanother developer.
  13. 13. e rs l op e veD A B C D E Custom ers 1 2 3 4 5 6
  14. 14. One month later...
  15. 15. Some one u Eclips pdated e can our S t use VN.anymo it re
  16. 16. Oh, it took m e 15 minutesto update Ec lipse and theSVN plugin
  17. 17. And this was only the first of 50 VMs!!!
  18. 18. Automated VM creation Vagrant Java Virtu alBox Puppet Chef
  19. 19. Vagrant
  20. 20. Vagrant Vagrant•configure virtual machines by script manage create•create new instances on the fly•manage the VM lifecycle VM
  21. 21. Vagrant add template VM to Vagrant $ vagrant box add lucid32 http:// files.vagrantup.com/lucid32.box $ vagrant init lucid32 creates VM configuration-script $ vagrant up start the virtual machine
  22. 22. Vagrant•build on top of VirtualBox•written in Ruby access by shell & Ruby
  23. 23. Vagrant Ubuntu Lucid 32- & 64 -bit•provides 2 template boxes by default•simple config-files it´s just Ruby Vagrant::Config.run do |config| config.vm.box = "lucid32" end see great Vagrant documentation•easy ssh connection, shared folder, etc.
  24. 24. Demo
  25. 25. Puppet
  26. 26. Puppet•configure your machines (nodes) by script•install and configure software & services
  27. 27. Puppet class apache { exec { apt-get update: command => /usr/bin/apt-get update } package { "apache2": ensure => present, Ap ache2 is installed } & started on node service { "apache2": ensure => running, require => Package["apache2"], } } include apache
  28. 28. Puppet•package individual components in modules•many online documentations & books out there
  29. 29. Vagrant &Puppet
  30. 30. Vagrant & Puppet•define your VM with Vagrant & configure it with Puppet•Puppet is pre-installed on Vagrant boxes
  31. 31. Vagrant & Puppet VagrantfileVagrant::Config.run do |config| config.vm.box = "lucid32" config.vm.provision :puppet do |puppet| puppet.manifests_path = "manifests" puppet.manifest_file = "my_manifest.pp" endend ppet script path to Pu
  32. 32. Demo
  33. 33. Vagrant-Binding manage co nfigure & VMs in Java
  34. 34. Vagrant-Binding•Java Wrapper around Vagrant•create & start VMs at runtime•only VirtualBox is required
  35. 35. Vagrant-Binding•Builder APIs•JUnit support•Puppet support
  36. 36. Builder APIVagrantVmConfig vmConfig = new VagrantVmConfigBuilder()! ! ! ! .withLucid32Box()! ! ! ! .withName("myLittleVm") builder API for VM! ! ! ! .withHostOnlyIp("192.168.50.4")! ! ! ! .build(); also builder APIVagrantEnvironment environment = ...; availableenvironment.up(); manage VM lifecycle! ! !environment.getVm(0).createConnection().execute("touch /tmp1");environment.destroy(); ssh connection
  37. 37. Demo
  38. 38. JUnit support st not reachable?@Testpublic void testJdbc() { what if ho dbHandler = new MySql(ip, db, user, pwd); dbHandler.createMyTable(); what if table already dbHandler.insertRow(); exists? assertEquals(1, dbHandler.getRowCount()); dbHandler.close(); parallel proces ses?}
  39. 39. JUnit support@Rule JUnit annotation manage VM lifecyclepublic VagrantTestRule testRule = new VagrantTestRule(createConfig());public static VagrantConfiguration createConfig() { //Configure VM with MySQL-Server & static ip} use builder API for VM spec ification create VM start VM run UnitTest destroy VM
  40. 40. Demo
  41. 41. Puppet Forge accessFile moduleFolder = new File("...");PuppetForgeClient client = new PuppetForgeClient();! !! !List<PuppetForgeModuleDescription> allDescriptions =! client.findModules("mongodb"); search! !for(PuppetForgeModuleDescription desc : allDescriptions) {! System.out.println("Installing " + desc.getFullName());! PuppetForgeModule module = client.findModule(desc);! client.installToModulesDir(moduleFolder, module);} module at install as runtime
  42. 42. Demo
  43. 43. Vagrant-Binding fork me on github https://github.com/guigarage/vagrant-binding
  44. 44. Roadmap • Remove VirtualBox as dependency (VMWare & AWS support) • Chef support • Simpler management of Environments • Better Builder APIs • Create Vagrant boxes at runtime
  45. 45. Thanks forwatching @hendrikEbbers www.guigarage.com hendrik.ebbers@web.de

×