Getting Started with Vagrant

Getting Started with Vagrant

Talk presented at DevFest Women in Istanbul #womentechmakers

719435d98d452de7ac367c828266cf01?s=128

Erika Heidi

March 02, 2014
Tweet

Transcript

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

    <independent> developer, eventually sysadmin • Author of Vagrant Cookbook on LeanPub
  3. What to expect from this talk • Introduction to Vagrant

    – Terminology, basic usage • Provisioning – Choosing a Provisioner – Practical Example with Ansible • ProTips • Useful Resources
  4. None
  5. “It works on my machine” - every developer, ever

  6. 1.1 Why Vagrant • Reproducible and portable development environment •

    Enables easier code collaboration • Backend env tests / benchmark • Automation Tools learning and testing
  7. 1.2 What you need (basic) • Vagrant [1.4.x] • VirtualBox

    [4.3.x]
  8. None
  9. 1.3 Terminology • Boxes • Host and Guest • Provider

    • Provisioner • Synced Folder • Vagrantfile
  10. 1.4 Getting Started 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
  11. Output

  12. None
  13. None
  14. 2.1 Shell x Automation Tools • Automation Tools have powerful

    built-in features – Clear language – Idempotent State – Templating – Modularization
  15. 2.2 Automation Tools PUPPET CHEF ANSIBLE Syntax Custom based on

    Ruby Ruby YAML Terminology Manifests / Modules Recipes / CookBooks Playbooks / Roles Exec. Order Not sequential Sequential Sequential Documentation Confusing Chaotic Excellent Popularity 1st 2nd 3rd Extra Requirements - - ansible Overall Learning Curve Moderate High Low
  16. Pratical Example Nginx + PHP5: Ansible

  17. Vagrantfile config.vm.provision "ansible" do |ansible| ansible.playbook = "playbook.yml" end

  18. Playbook --- - hosts: all sudo: true tasks: - name:

    Update apt apt: update_cache=yes - name: Install Nginx apt: pkg=nginx state=latest - name: Install PHP5-fpm apt: pkg=php5-fpm state=latest
  19. Output

  20. None
  21. 3.1 Installing Packages • Package managers are usually outdated –

    Make SURE you run apt-get update first
  22. 3.2 Debugging • Unknown Vagrant error – Use VirtualBox /

    Vmware GUI • Unknown Provisioner error – Increase provisioner verbosity • Not working as expected – Login, fix, automate
  23. None
  24. Vagrant Cookbook Special discount coupon for DevFest Women: http://leanpub.com/vagrantcookbook/c/devfestw

  25. puphpet.com

  26. phansible.com

  27. Comparing Provisioners • Sandbox-PHP – Ansible, Puppet and Chef provisionings

    – https://github.com/vagrantee/sandbox-php
  28. @erikaheidi