Testumgebungen mit Vagrant

17
Testumgebungen mit Vagrant Ronald Richter

description

Vortrag über Testumgebungen mit Vagrant beim Wordpress Meetup am 23.10.2013

Transcript of Testumgebungen mit Vagrant

Page 1: Testumgebungen mit Vagrant

Testumgebungen

mit

VagrantRonald Richter

Page 2: Testumgebungen mit Vagrant

Wie sieht Eure Test- bzw.Entwicklungsumgebung aus?

Testumgebungen mit Vagrant WP-Meetup Hannover - 23. Okt. 2013

Page 3: Testumgebungen mit Vagrant

Meine Test-/Entwicklungsumgebungen im Laufeder Zeit

1. Apache, PHP und MySQL auf der lokalen Maschine mit VirtualHost-Umgebungen

2. Dedizierte Maschine, die via NFS bzw. FTP/SCP die Daten erhält.

3. Virtuelle Systeme

4. Vagrant

Testumgebungen mit Vagrant WP-Meetup Hannover - 23. Okt. 2013

Page 4: Testumgebungen mit Vagrant

Vagrant• Mitchell Hashimoto startete 2010 mit der Entwicklung von Vagrant.

• Vagrant is a tool for building complete development enviroments.(VagrantUp.com/about.html)

• Seit November 2012 liegt die Entwicklung bei der Firma HashiCorp

• Vagrant ist in Ruby geschrieben.

Testumgebungen mit Vagrant WP-Meetup Hannover - 23. Okt. 2013

Page 5: Testumgebungen mit Vagrant

Vagrant - Provider• Ursprünglich nutzte Vagrant für die Virtualisierung ausschließlich Virtualbox

• Heute gibt es auch Provider für

• VMWare Fusion

• Amazon EC2 (AWS)

• Windows Virtual PC (AWS)

• LXC

• …

Testumgebungen mit Vagrant WP-Meetup Hannover - 23. Okt. 2013

Page 6: Testumgebungen mit Vagrant

VirtualBox• Die Firma InnoTek Systemberatung GmbH begann 2004 mit der Entwicklung

• InnoTek wurde dann im Februar 2008 von Sun Microsystem übernommen.

• Sun Microsystem wurde wiederum im Januar 2010 von Oracle aufgekauft.

• Die ersten Versionen wurden unter einer proprietären Lizenz (PUEL) von Innotek verkauft.

• Ab 2007 gibt es auch eine Open Source Edition (OSE), die unter dar GNU GeneralLicense (GPL) stand, aber nicht alle Funktionen enthielt.

• Seit Dezember 2010 mit der Version 4.0 gibt es nur noch die OSE. Die kostenpflichtigenFunktionen werden als Oracle VM VirtualBox Extension Pack vertrieben. Sie stehen aberfür den persönlichen und akademischen Gebrauch kostenfrei zur Verfügung.

Testumgebungen mit Vagrant WP-Meetup Hannover - 23. Okt. 2013

Page 7: Testumgebungen mit Vagrant

VirtualBox - Oracle VM VirtualBox Extension Pack• Das Oracle VM VirtualBox Extension Pack enthält Support für:

• Virtuelle USB 2.0 Schnittstelle

• Remote Desktop Protocol (VRDP) inkl. USB über RDP

• PXE-Boot für E1000 Netzwerkkarten

• PCI-Passthrough unter LinuX

Testumgebungen mit Vagrant WP-Meetup Hannover - 23. Okt. 2013

Page 8: Testumgebungen mit Vagrant

VirtualBox - Hostsysteme• VirtualBox gibt es für:

• Windows

• OS X

• LinuX

• Solaris• Lizenz kostet 39€/Named User Plus

Webseite: http://www.virtualbox.org

Testumgebungen mit Vagrant WP-Meetup Hannover - 23. Okt. 2013

Page 9: Testumgebungen mit Vagrant

Vagrant Demo

DEMO

Testumgebungen mit Vagrant WP-Meetup Hannover - 23. Okt. 2013

Page 10: Testumgebungen mit Vagrant

Vagrant Demo II - init1 > vagrant init precise32 http://files.vagrantup.com/precise32.box2 A `Vagrantfile` has been placed in this directory. You are now3 ready to `vagrant up` your first virtual environment! Please read4 the comments in the Vagrantfile as well as documentation on5 `vagrantup.com` for more information on using Vagrant.

Testumgebungen mit Vagrant WP-Meetup Hannover - 23. Okt. 2013

Page 11: Testumgebungen mit Vagrant

Vagrant Demo II - up 1 > vagrant up 2 Bringing machine 'default' up with 'virtualbox' provider... 3 [default] Box 'precise32' was not found. Fetching box from specified URL for the 4 provider 'virtualbox'. Note that if the URL does not have a box for this provider, 5 you should interrupt Vagrant now and add the box yourself. Otherwise Vagrant will 6 will attempt to download the full box prior to discovering this error. 7 Downloading or copying the box... 8 Extracting box...te: 1623k/s, Estimated time remaining: 0:00:01) 9 Successfully added box 'precise32' with provider 'virtualbox'!10 [default] Importing base box 'precise32'...11 [default] Matching MAC address for NAT networking...12 [default] Setting the name of the VM...13 [default] Clearing any previously set forwarded ports...14 [default] Creating shared folders metadata...15 [default] Clearing any previously set network interfaces...16 [default] Preparing network interfaces based on configuration...17 [default] Forwarding ports...18 [default] -- 22 => 2222 (adapter 1)19 [default] Booting VM...20 [default] Waiting for VM to boot. This can take a few minutes.21 [default] VM booted and ready for use!22 [default] Configuring and enabling network interfaces...23 [default] Mounting shared folders...24 [default] -- /vagrant

Testumgebungen mit Vagrant WP-Meetup Hannover - 23. Okt. 2013

Page 12: Testumgebungen mit Vagrant

Vagrant Demo II - ssh1 > vagrant ssh2 Welcome to Ubuntu 12.04 LTS (GNU/Linux 3.2.0-23-generic-pae i686)3 4 * Documentation: https://help.ubuntu.com/5 Welcome to your Vagrant-built virtual machine.6 Last login: Fri Sep 14 06:22:31 2012 from 10.0.2.2

Testumgebungen mit Vagrant WP-Meetup Hannover - 23. Okt. 2013

Page 13: Testumgebungen mit Vagrant

Vagrant - Boxen• Vorlagen können selbst erstellt werden.

• Es gibt unter anderem bereits fertige Boxvorlagen für:

• Archlinux

• CentOS

• Debian

• Fedora

• Ubuntu

• OpenBSD

• OpenSuse

• Oracle Linux

• …• Eine Übersicht über fertige Boxen gibt die Seite http://vagrantbox.es

Testumgebungen mit Vagrant WP-Meetup Hannover - 23. Okt. 2013

Page 14: Testumgebungen mit Vagrant

Vagrant - Konfiguration• Einfache Konfiguration wird via vagrant init im aktuellen Ordner angelegt.

1 # -*- mode: ruby -*- 2 # vi: set ft=ruby : 3 4 Vagrant.configure("2") do |config| 5 # All Vagrant configuration is done here. The most common configuration 6 # options are documented and commented below. For a complete reference, 7 # please see the online documentation at vagrantup.com. 8 9 # Every Vagrant virtual environment requires a box to build off of.10 config.vm.box = "precise32"11 12 # The url from where the 'config.vm.box' box will be fetched if it13 # doesn't already exist on the user's system.14 config.vm.box_url = "http://files.vagrantup.com/precise32.box"15 16 # Create a forwarded port mapping which allows access to a specific port17 # within the machine from a port on the host machine. In the example below,18 # accessing "localhost:8080" will access port 80 on the guest machine.19 # config.vm.network :forwarded_port, guest: 80, host: 808020 21 # …22 end

Testumgebungen mit Vagrant WP-Meetup Hannover - 23. Okt. 2013

Page 15: Testumgebungen mit Vagrant

Vagrant - Provision• Es unterstützt verschiedene Techniken zur Provisionierung der Umgebung

• Shell-Skripte

• Ansible

• Chef (Solo & Client)

• Puppet (Apply & Agent)

Webseite: http://www.vagrantup.com

Testumgebungen mit Vagrant WP-Meetup Hannover - 23. Okt. 2013

Page 16: Testumgebungen mit Vagrant

Demos• Buildumgebung für OpenWRT (=> Shell)

• Testsystem für die Wassersportfreude von 1898 e.V. (=> Puppet Apply)

• ???

Testumgebungen mit Vagrant WP-Meetup Hannover - 23. Okt. 2013

Page 17: Testumgebungen mit Vagrant

Letzte Folie

Vielen Dank für Eure Geduld!

Testumgebungen mit Vagrant WP-Meetup Hannover - 23. Okt. 2013