Lightweight and reproducible environments with vagrant and Puppet

3,502 views

Published on

0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,502
On SlideShare
0
From Embeds
0
Number of Embeds
7
Actions
Shares
0
Downloads
70
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Lightweight and reproducible environments with vagrant and Puppet

  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 @hendrikEbbers www.guigarage.com hendrik.ebbers@web.de
  3. 3. Content•Vagrant•Puppet•Java Vagrant-Binding API
  4. 4. Vagrant
  5. 5. Vagrant Vagrant manage lifecycle•configure virtual machines by script create•create new instances on the fly•manage the VM lifecycle VM
  6. 6. 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
  7. 7. Vagrant•build on top of VirtualBox•written in Ruby by shel l & Ruby access
  8. 8. Vagrant Ubuntu 32- & 64 Lucid -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.
  9. 9. Puppet
  10. 10. Puppet•configure your machines (nodes) by script•install and configure software & services
  11. 11. Puppet class apache { exec { apt-get update: command => /usr/bin/apt-get update } package { "apache2": ensure => present, Ap ache2 is installed } service { "apache2": & started on node ensure => running, require => Package["apache2"], } } include apache
  12. 12. Puppet•package individual components in modules•many online documentations & books out there
  13. 13. Vagrant &Puppet
  14. 14. Vagrant & Puppet•define your VM with Vagrant & configure it with Puppet•Puppet is pre-installed on Vagrant boxes
  15. 15. 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 path to Puppet script
  16. 16. Vagrant-Binding ure & manage config VMs in Java
  17. 17. Vagrant-Binding•Java Wrapper around Vagrant•create & start VMs at runtime•only VirtualBox is required
  18. 18. Vagrant-Binding•Builder APIs•JUnit support•Puppet support
  19. 19. Builder APIVagrantVmConfig vmConfig = new VagrantVmConfigBuilder()! ! ! ! .withLucid32Box()! ! ! ! .withName("myLittleVm") builder API for VM! ! ! ! .withHostOnlyIp("192.168.50.4")! ! ! ! .build(); also builder APIVagrantEnvironment environment = ...; availableenvironment.up(); mana ge VM lifecycle! ! !environment.getVm(0).createConnection().execute("touch /tmp1");environment.destroy(); ssh connection
  20. 20. JUnit support@Test wh at if host notpublic void testJdbc() { reachable? dbHandler = new MySql(ip, db, user, pwd); dbHandler.createMyTable(); what if table already exists? dbHandler.insertRow(); assertEquals(1, dbHandler.getRowCount()); dbHandler.close(); parallel proces ses?}
  21. 21. JUnit support JUnit annotation manage VM lifecycle@Rulepublic 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
  22. 22. Vagrant-Binding fork me on github https://github.com/guigarage/vagrant-binding
  23. 23. Thanks forwatching @hendrikEbbers www.guigarage.com hendrik.ebbers@web.de

×