Vagrant - How to make your
   Dev-Env awesome.

  Eine kleine Einführung in puppet
            und vagrant.

    Sönke Ruempler -- @s0enke

     PHP Unconference 2011
Ich


      "last level support" - von strace bis OOP

                "WannaBe-DevOP"

                "Systems thinking"
Jimdo

Website Builder

seit 2007

"Startup"

5 Millionen Registrations

12 Sprachen
Agenda

a.k.a. "Der Inhalt ist immer invers proportional zum Aufwand,
der ins Layout gesteckt wurde" :-)


 ● Was ist Konfigurationsmanagement?
 ● Was ist puppet?
 ● Was ist vagrant?
 ● Live-Hacking: Starten eines kleinen Clusters auf dem
   Laptop inkl. einer Hello-World-App
Configuration Management

Wer kennt es?

Wie setzt ihr Server auf?

 ● Golden Image?
 ● Bash Script?
 ● Wiki?
 ● Tool?
Server-Admin Probleme

     Wie setze ich einen Server reproduzierbar auf?

                         Denn:

     Wiki / Doku verstaubt oder wird nicht gefunden

 Wie hält man es auf Stand? Einloggen auf alle n Server?
http://www.slideshare.net/socializedsoftware/crash-course-in-open-source-cloud-computing
Infrastructure as code




          http://www.puppetlabs.com/
ausführbare, testbare und versionierte
            Server-Dokumentation

Config-Deployment schnell, oft und reproduzierbar
seit 2004
eine deklarative, abstrakte DSL für Sysadmins, um
       Systemkonfiguration zu beschreiben
Idempotent




             f(x) = f(f(x))
Manifests
puppet classes

class webserver {
   package { "apache2":
      ensure => present, # apt-get etc.
   }
   file { "/etc/apache2/apache2.conf" :
      ensure => present
      source =>
         "puppet:///apache2/apache2.conf"
   }
}
puppet nodes

node "web" {
  $db_server = "db1"
   include webserver

}

node db1, db2, db3 {
    include mysql
}
Services

Modules (google: "puppet <package/daemon>")

           Variables, Templates

         Inheritance, zB bei Nodes
http://www.puppetlabs.com/puppet/how-puppet-works/
Client / Server
?

Questions so far ...
vagrant - even the logo is cool!




    www.vagrantup.com - kudos to Mitchell Hashimto
Dev-Umgebung: Ist-Analyse

Wie entwickelt ihr und wie setzt ihr euer Dev-System auf?

 ● Lokal auf dem Desktop?
 ● Testserver?
 ● Sandboxes auf VM-Server?
 ● lokale VMs?
 ● Noch anders?
Soll-Zustand
(Businessanforderungen)
vagrant to the rescue!
Soll-Zustand I

               Isolation der Testumgebung

                            vs.

    Dein Desktop - ein Softwarezoo: Browser, Webserver,
           Musikplayer, Datenbankserver, Editor)

                           oder

 geteilter Testserver: Shared Ressourcen, Shared Software ->
Kollisionen (Beispiel: memcache keys oder "Lass uns mal PHP
                        5.3 ausprobieren")
Soll-Zustand II

                       Wiederholbar

                             vs.

 nach 6 Monaten findet Kunde einen Bug, wie lange brauchst
     du, um das Projekt "rauszukramen" und den Fehler
                 zu reproduzieren / fixen ?

     oder z. B. lange Einrichtung bei Neuem Mitarbeiter /
                       Projektbeteiligter

     oder: 3 Wochen Urlaub, Testsystem völig outdated
Soll-Zustand III

                       Einheitlichkeit

                             vs.

                  "It works on my machine"

              Anderes OS als in Produktion (!)

Andere Kernel (32 vs. 64bit), Libs, Software und Versionen als
                        in Produktion

                  ... PHP (is_a() anyone?)
Definition: Was ist vagrant

"Vagrant is a tool for building and distributing virtualized
development environments."

"By providing automated creation and provisioning of virtual
machines using Oracle’s VirtualBox, Vagrant provides the
tools to create and configure lightweight, reproducible, and
portable virtual environments.
Was ist vagrant?

● "Dev-Env zum Mitnehmen"
● Verwaltung des VM Lebenszyklus
● Shared Folders / lokales NFS
● SSH
● Konfiguration der VMs via Puppet / Chef / bash-script
● komplexe Multi-VM-Setups inkl. privatem Netzwerk
● Framework zur Erstellung von VM-BaseImages (Base
  Boxes)
Vagrantfile

 ● Beschreibt die VM(s)
 ● Eins pro Projekt - kommt mit in die Versionskontrolle
   deines Projekts
 ● Configfile ist Ruby (und damit scriptbar)




That's it (für eine VM)!
==

Hardware        Software
Workflow(s)

vagrant init
vagrant up
vagrant reload
vagrant provision
vagrant ssh
vagrant halt
vagrant destroy
NO! ZOMG ACTION!!11
Action!


soenke♥kellerautomat:~$ gem install vagrant
beyond ...

               Vagrant -> Cloud: mccloud

 (https://github.com/jedi4ever/mccloud (by Patrick Debois -
                   father of devopsdays!))


         cucumber-nagios: Ecosystem as Code


  cucumber-puppet: Behavior Driven Administration

Einführung in Puppet und Vagrant