Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Vagrant for PHP Developers

Erika Heidi
January 24, 2014

Vagrant for PHP Developers

Slides for my talk at PHPBenelux 2014

Erika Heidi

January 24, 2014
Tweet

More Decks by Erika Heidi

Other Decks in Programming

Transcript

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

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

    • Provisioner Tasting: Ansible, Puppet and Chef • Vagrant usage research – results
  3. 1. Why Vagrant • Reproducible and portable dev environment •

    Enables easier code collaboration • Backend env tests / benchmark • Automation Tools learning and testing
  4. 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
  5. 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
  6. 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
  7. 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
  8. 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
  9. 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
  10. 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).
  11. 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
  12. 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
  13. 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'], }
  14. 5.3 Chef (chef_solo) Syntax Ruby Scripts Recipes Execution Order Sequential

    Modularity Many “cookbooks” available on internet Popularity Popular, big community Documentation Chaos!
  15. 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/
  16. Vagrant Cookbook • A practical e-book about Vagrant and its

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

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