Lightweight and reproducible environments with
& Java About me Hendrik Ebbers Lead of development at SIC GmbH - - PowerPoint PPT Presentation
& Java About me Hendrik Ebbers Lead of development at SIC GmbH - - PowerPoint PPT Presentation
Lightweight and reproducible environments with Vagrant & Puppet & Java About me Hendrik Ebbers Lead of development at SIC GmbH in Dortmund, Germany Lead of JUG Dortmund @hendrikEbbers www.guigarage.com
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
Content
- Vagrant
- Puppet
- Java Vagrant-Binding API
Vagrant
Vagrant
- configure virtual machines by script
- create new instances on the fly
- manage the VM lifecycle
Vagrant VM c r e a t e manage lifecycle
$ vagrant box add lucid32 http:// files.vagrantup.com/lucid32.box $ vagrant init lucid32 $ vagrant up
Vagrant
add template VM to Vagrant creates VM configuration-script s t a r t t h e v i r t u a l m a c h i n e
Vagrant
- build on top of VirtualBox
- written in Ruby
access by shell & Ruby
Vagrant
- provides 2 template boxes by default
- simple config-files
- easy ssh connection, shared folder, etc.
Vagrant::Config.run do |config| config.vm.box = "lucid32" end
Ubuntu Lucid 32- & 64-bit it´s just Ruby s e e g r e a t V a g r a n t d
- c
u m e n t a t i
- n
Puppet
Puppet
- configure your machines (nodes) by script
- install and configure software & services
Puppet
class apache { exec { 'apt-get update': command => '/usr/bin/apt-get update' } package { "apache2": ensure => present, } service { "apache2": ensure => running, require => Package["apache2"], } } include apache Apache2 is installed & started on node
Puppet
- package individual components in modules
- many online documentations & books out
there
Vagrant & Puppet
Vagrant & Puppet
- define your VM with Vagrant & configure it
with Puppet
- Puppet is pre-installed on Vagrant boxes
Vagrant & Puppet
Vagrant::Config.run do |config| config.vm.box = "lucid32" config.vm.provision :puppet do |puppet| puppet.manifests_path = "manifests" puppet.manifest_file = "my_manifest.pp" end end
p a t h t
- P
u p p e t s c r i p t V a g r a n t f i l e
Vagrant- Binding
c
- n
f i g u r e & m a n a g e V M s i n J a v a
Vagrant-Binding
- Java Wrapper around Vagrant
- create & start VMs at runtime
- only VirtualBox is required
Vagrant-Binding
- Builder APIs
- JUnit support
- Puppet support
Builder API
VagrantVmConfig vmConfig = new VagrantVmConfigBuilder() .withLucid32Box() .withName("myLittleVm") .withHostOnlyIp("192.168.50.4") .build(); VagrantEnvironment environment = ...; environment.up(); environment.getVm(0).createConnection().execute("touch /tmp1"); environment.destroy();
a l s
- b
u i l d e r A P I a v a i l a b l e builder API for VM manage VM lifecycle s s h c
- n
n e c t i
- n
JUnit support
@Test public void testJdbc() { dbHandler = new MySql(ip, db, user, pwd); dbHandler.createMyTable(); dbHandler.insertRow(); assertEquals(1, dbHandler.getRowCount()); dbHandler.close(); } what if table already exists? what if host not reachable? p a r a l l e l p r
- c
e s s e s ?
JUnit support
@Rule public VagrantTestRule testRule = new VagrantTestRule(createConfig()); public static VagrantConfiguration createConfig() { //Configure VM with MySQL-Server & static ip } create VM start VM run UnitTest destroy VM JUnit annotation m a n a g e V M l i f e c y c l e use builder API for VM specification
Vagrant-Binding
https://github.com/guigarage/vagrant-binding
fork me on github
Thanks for watching
@hendrikEbbers www.guigarage.com hendrik.ebbers@web.de