Love thy vagrant

Db6218c1b56d64e775eb79ea4f2889dd?s=47 Sebastian
November 22, 2013

Love thy vagrant

An introduction to vagrant for DrupalCamp 2013. Aimed at beginners, in this talk I talk about providers, provisioners and plugins. I also cover best practices and address problems which vagrant may introduce.

Db6218c1b56d64e775eb79ea4f2889dd?s=128

Sebastian

November 22, 2013
Tweet

Transcript

  1. Love thy vagrant DrupcalCamp Vienna 2013 Sebastian Göttschkes

  2. 3 reasons

  3. 3 reasons

  4. 3 reasons http://simply-the-test.blogspot.co.at/2010/05/it-works-on-my-machine.html

  5. 3 reasons

  6. @Sgoettschkes # music # bodymod # symfony # agile #

    devops
  7. Wogibtswas

  8. Coming up • What vagrant really is • How you

    can start using vagrant today (or tomorrow if you don’t want to miss the other awesome talks) • Some neat tricks • The downside of vagrant
  9. The dark times

  10. The dark times Word, Outlook, “nice” GUI “Compatible with work”

    Host Sourcecode, IDE, Stack “Development” VM
  11. The dark times Sourcecode, IDE localhost Synced Folder Apache, PHP,

    MYSQL Remote VM Sync Sourcecode Run commands
  12. The dark cloud times

  13. Enter vagrant

  14. Enter vagrant • Configuration: Vagrantfile • Boxes: Exported Virtual Machines

    + metadata • Providers: VirtualBox • Synced folders: Folders from the host which are dublicated inside the VM • Provisioners: Shell / ansible / Chef / Puppet • Plugins: Way to extend Vagrant with additional Providers, Provisioners and other stuff
  15. The Vagrantfile Vagrant.configure("2") do |config| config.vm.network "private_network", ip: "10.61.6.2" config.vm.hostname

    = "drupal" config.vm.box = "precise64" config.vm.box_url = "http://files.vagrantup.com/precise64.box" config.vm.synced_folder "../project", "/var/www/project" config.vm.provision shell, inline: "sudo apt-get update" end
  16. Configuration Vagrant.configure("2") do |config| config.vm.network "private_network", ip: "10.61.6.2" config.vm.hostname =

    "drupal" config.vm.box = "precise64" config.vm.box_url = "http://files.vagrantup.com/precise64.box" config.vm.synced_folder "../project", "/var/www/project" config.vm.provision shell, inline: "sudo apt-get update" end
  17. The boxes Vagrant.configure("2") do |config| config.vm.network "private_network", ip: "10.61.6.2" config.vm.hostname

    = "drupal" config.vm.box = "precise64" config.vm.box_url = "http://files.vagrantup.com/precise64.box" config.vm.synced_folder "../project", "/var/www/project" config.vm.provision shell, inline: "sudo apt-get update" end
  18. Providers

  19. Synced folders Vagrant.configure("2") do |config| config.vm.network "private_network", ip: "10.61.6.2" config.vm.hostname

    = "drupal" config.vm.box = "precise64" config.vm.box_url = "http://files.vagrantup.com/precise64.box" config.vm.synced_folder "../project", "/var/www/project" config.vm.provision shell, inline: "sudo apt-get update" end
  20. Provisioning Vagrant.configure("2") do |config| config.vm.network "private_network", ip: "10.61.6.2" config.vm.hostname =

    "drupal" config.vm.box = "precise64" config.vm.box_url = "http://files.vagrantup.com/precise64.box" config.vm.synced_folder "../project", "/var/www/project" config.vm.provision shell, inline: "sudo apt-get update" end
  21. Shell Provisioning Vagrant.configure("2") do |config| # … config.vm.provision "shell", inline:

    $script config.vm.provision “shell”, path: "provision.sh" end $script = <<SCRIPT apt-get update apt-get install -y python-software-properties SCRIPT
  22. Ansible Provisioning --- tasks: - name: Install nginx apt: pkg=nginx

    state=latest - name: Copy nginx config copy: src=nginx.conf dest=/etc/nginx/nginx.conf - name: Install mongodb pecl module command: pecl install -f mongo
  23. Chef Provisioning package "nginx" do action :install end template "/etc/nginx/nginx.conf"

    do source "nginx.conf.erb" action :create end execute "pecl install -f mongo" do action :run end
  24. Puppet Provisioning package { nginx: ensure => installed } file

    { "/etc/nginx/nginx.conf": source => "nginx.conf" } exec { "install mongo from pecl": command => 'pecl install -f mongo', }
  25. Plugins # AWS provider $ vagrant plugin install vagrant-aws #

    Boxen provisioner $ vagrant plugin install ventriloquist # Manage host files $ vagrant plugin install vagrant-hostmanager # Make screenshots of your VM $ vagrant plugin install vagrant-camera # … many more!
  26. A sample workflow Repository Vagrantfile Provisiong files … $ git

    clone git@github.com:vagrantLover/awesomeVm.git $ cd awesomeVm $ vagrant up # this may take a while $ vagrant ssh
  27. Real world vagrant vs

  28. Real world vagrant apache php python ruby nodejs mysql mongodb

    redis project1 project2 python-stuff crazy-idea vs apache php mysql apache php mongodb redis apache php nodejs mysql project1 project2 project3
  29. Real world vagrant Ubuntu box #1 Ubuntu box #3 Ubuntu

    box #2 Ubuntu box #4 Ubuntu box #5 Debian box #1 Debian box #2 Debian box #3 Arch box #1 Arch box #2 vs Ubuntu base box Debian base box Arch base box
  30. Real world vagrant

  31. Real world vagrant Yet Another Tool?

  32. Real world vagrant Which provider? Which base box? Which provisioner?

    How should I start? How to best solve X? Do I need many vms? How should I switch? What if anything goes wrong?
  33. Real world vagrant Which provider? Which base box? Which provisioner?

    How should I start? How to best solve X? Do I need many vms? How should I switch? What if anything goes wrong? Would you start already?