Vagrant – Development environments made easy – $vagrant init



Vagrant – Development environments made easy – $vagrant init

0 1


vagrant-dev-enviroments-made-easy

Slides zum Vortrag: Vagrant - Development environments made easy

On Github Wichteldesign / vagrant-dev-enviroments-made-easy

Vagrant

Development environments made easy

Felix Peters / @el_wichtel

Felix Peters

Vollblut Onliner und PHP-Entwickler

www.wichteldesign.de / www.felixpeters.de

Twitter: @el_wichtel

Github: Wichteldesign

$vagrant init

Eine kurze Einführung

Wie arbeitet ihr bisher?

Linux? Ok, easy...

MAMP/XAMPP?

Virtual Box?

Direkt am Server?

Was ganz anderes? (erzählen!)

"For me it works"

- unknown developer -

Create and configure lightweight, reproducible, and portable development environments. www.vagrantup.com

Configuration

+ Provider

+ Provisioner

+ Plugins

= Vagrant

Configuration (Vagrantfile)

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "hashicorp/precise64"  
  config.vm.network "forwarded_port", guest: 80, host: 8081
  config.vm.synced_folder "vagrant", "/var/www/vagrant"

  config.vm.provider "virtualbox" do |vb|
      vb.customize ["modifyvm", :id, "--memory", "1024"]
  end

  config.vm.provision "chef_solo" do |chef|
     chef.add_role "webserver"
    }
  end
end

http://docs.vagrantup.com/v2/vagrantfile/index.html

Provider

VirtualBox, VMware, Docker, Hyper-V, Amazon AWS, Rackspace, ...

 

Boxen

Images von vorinstallierten Systemen (Linux, Windows, ...)

https://vagrantcloud.com

Sind Provider abhängig!

http://docs.vagrantup.com/v2/getting-started/boxes.html

Provisioner

Shell, Chef, Puppet, Ansible, Docker, Salt, ...

http://www.wix.com/blog/wp-content/uploads/2012/01/WhopperVMcDonalds.jpg

Hier wird's tricky, aber mächtig!

http://docs.vagrantup.com/v2/provisioning/index.html

"Configuration as Code"

"Code your desired system state"

 

Dokumentierte Umgebung

Versionierbar

Wiederholbar - auf Dev, Stage und Live!

Plugins

Plugins are powerful, first-class citizens that extend Vagrant using a well-documented, stable API that can withstand major version upgrades.

Erweitern Vagrant um weitere nützliche Funktionen

z.B Package Manager für Provisioner wie librarian usw.

Provider für AWS, Racksapce, ...

https://github.com/mitchellh/vagrant/wiki/Available-Vagrant-Plugins

Die coolen Features

Synced Folder

Ordner zwischen Gast-System und VM syncronisieren

RSync, SMB, NFS, VirtualBox

              config.vm.synced_folder "vagrant", "/var/www/vagrant"
            

http://docs.vagrantup.com/v2/synced-folders/index.html

Network

FORWARDED PORTS

Lokale Ports auf die VM mappen und weiterleiten

              Vagrant.configure("2") do |config|
                config.vm.network "forwarded_port", guest: 80, host: 8080
              end
            

http://docs.vagrantup.com/v2/networking/index.html

VAGRANT SHARE

Neu seit Vagrant 1.5

Tunnel in die VM von außerhalb (z.B. für Payment Systeme)

Alternative: Ngrok

http://docs.vagrantup.com/v2/share/index.html

MULTI-MACHINE

Production Umgebung nachstellen

Mehrerer VM's deployen aus einer Konfiguration

API lokal testen

Ausfälle, Cluster usw. lokal testen

  Vagrant.configure("2") do |config|
    config.vm.provision "shell", inline: "echo Hello"

    config.vm.define "web" do |web|
      web.vm.box = "apache"
    end

    config.vm.define "db" do |db|
      db.vm.box = "mysql"
    end
  end
              

http://docs.vagrantup.com/v2/multi-machine/index.html

Continuous Integration

Jenkins kann Vagrant Boxen starten und deployen

https://wiki.jenkins-ci.org/display/JENKINS/Vagrant+Plugin

Phansible

http://phansible.com/

PUPHPET

https://puphpet.com/

Demo-Time!

$vagrant up