Vagrant for PHP Developers

719435d98d452de7ac367c828266cf01?s=47 Erika Heidi
January 24, 2014

Vagrant for PHP Developers

Slides for my talk at PHPBenelux 2014

719435d98d452de7ac367c828266cf01?s=128

Erika Heidi

January 24, 2014
Tweet

Transcript

  1. None
  2. whoami • @erikaheidi • Brazilian, living in Amsterdam since 2012

    • PHP <independent> developer, eventually sysadmin • Using vagrant for about 1 year
  3. What to expect from this talk • Introduction to Vagrant

    • Provisioner Tasting: Ansible, Puppet and Chef • Vagrant usage research – results
  4. None
  5. “It works on my machine” - every developer, ever

  6. 1. Why Vagrant • Reproducible and portable dev environment •

    Enables easier code collaboration • Backend env tests / benchmark • Automation Tools learning and testing
  7. 2. How it Works • Vagrant manages vms using a

    Virtualization software like VirtualBox • Beyond that, it runs a provisioner to setup the vm environment • You just need to run vagrant up
  8. 3. What you need (basic) • Vagrant [1.4.x] • VirtualBox

    [4.3.x]
  9. 4. The Vagrantfile • Where you define the vagrant project

    settings Vagrant.configure("2") do |config| config.vm.box = "precise64" config.vm.box_url = "http://files.vagrantup.com/precise64.box" config.vm.provision "shell", inline: "echo hello, this is a simple Shell Provisioner!" end
  10. 4.1 Defining the Box # this is the simplest thing

    that does something Vagrant.configure("2") do |config| config.vm.box = "precise64" config.vm.box_url = "http://files.vagrantup.com/precise64.box" end
  11. 4.2 Defining the Network Vagrant.configure("2") do |config| config.vm.box = "precise64"

    config.vm.box_url = " http://files.vagrantup.com/precise64.box" config.vm.network :private_network, ip: "192.168.33.101" end
  12. 4.3 Defining a Provisioner Vagrant.configure("2") do |config| config.vm.box = "precise64"

    config.vm.box_url = "http://files.vagrantup.com/precise64.box" config.vm.network :private_network, ip: "192.168.33.101" config.vm.provision "shell", inline: "echo hello, this is a simple Shell Provisioner!" end
  13. 4.4 Shared Folder Vagrant.configure("2") do |config| config.vm.box = "precise64" config.vm.box_url

    = "http://files.vagrantup.com/precise64.box" config.vm.provision "shell", inline: "echo hello, this is a simple Shell Provisioner!" config.vm.synced_folder "./app", "/vagrant" end
  14. Output

  15. None
  16. None
  17. 5.1 Ansible Syntax YAML Scripts Playbooks Execution Order Sequential Modularity

    Many built-in modules Popularity Quite new, community is growing fast Documentation Clear, objective Note: requires installation of extra package (ansible).
  18. 5.1 Ansible: playbook #simple playbook example --- - hosts: all

    sudo: true Tasks: - name: Update apt apt: update_cache=yes - name: Install Nginx apt: pkg=nginx state=latest
  19. 5.1 Ansible: Output

  20. 5.2 Puppet (puppet-apply) Syntax Custom based on Ruby Scripts Manifests

    Execution Order NOT Sequential Modularity Very easy to find modules on internet Popularity Very popular, with a large community Documentation A bit confusing
  21. 5.2 Puppet: manifest #manifests/default.pp Exec { path => [ "/bin/",

    "/sbin/" , "/usr/bin/", "/usr/sbin/" ] } exec { 'apt-get update': command => 'apt-get update', } package { 'nginx': ensure => "installed", require => Exec['apt-get update'], }
  22. 5.2 Puppet: output

  23. 5.3 Chef (chef_solo) Syntax Ruby Scripts Recipes Execution Order Sequential

    Modularity Many “cookbooks” available on internet Popularity Popular, big community Documentation Chaos!
  24. 5.3 Chef: recipe #cookbooks/nginx/recipes/default.rb execute "apt-get update" do command "apt-get

    update" end apt_package "nginx" do action :install end
  25. 5.3 Chef: output

  26. None
  27. None
  28. None
  29. None
  30. None
  31. MORE RESOURCES

  32. Quickly getting started • Sandbox-PHP – Ansible, Puppet and Chef

    provisionings – https://github.com/vagrantee/sandbox-php • PuPHPet – Web interface, creates a Puppet provisioning – https://puphpet.com/
  33. Vagrant Cookbook • A practical e-book about Vagrant and its

    most popular provisioners • Link: https://leanpub.com/vagr antcookbook
  34. Summary • Vagrant – is awesome • Provisioners – Each

    one has pros and cons... it's up to you • Vagrant research – In first hand!
  35. QUESTIONS

  36. erikaheidi.com/vagrant