Vagrant crash course

download Vagrant crash course

of 94

  • date post

    20-May-2015
  • Category

    Documents

  • view

    3.394
  • download

    2

Embed Size (px)

description

A crash-course in the basics of using Vagrant.

Transcript of Vagrant crash course

  • 1. VagrantA Crash CourseMarcus Deglos [@manarth]TECHITO: Drupal. Architecture. Integration. Performance.

2. AN OVERVIEWTECHITO: Drupal. Architecture. Integration. Performance. 3. What is Vagrant? A tool for developers A VM management tool Automate the setup of yourdevelopment environmentTECHITO: Drupal. Architecture. Integration. Performance. 4. Has this happened to you?TECHITO: Drupal. Architecture. Integration. Performance. 5. New starter Someone joins your project They pick up their laptop Then spend the next 1-2 days followinginstructions on setting up theirenvironment, tools, etc.TECHITO: Drupal. Architecture. Integration. Performance. 6. Instead, lets do this.TECHITO: Drupal. Architecture. Integration. Performance. 7. New starter Someone joins your project They pick up their laptop Then spend the next 10 minutes running ascript which sets their environment up forthem.TECHITO: Drupal. Architecture. Integration. Performance. 8. STEP BY STEPTECHITO: Drupal. Architecture. Integration. Performance. 9. Prerequisites Virtualbox Vagrant Both Virtualbox and Vagrant have great,simple installation instructions.TECHITO: Drupal. Architecture. Integration. Performance. 10. SETTING UP THE BOXFollow these steps once Virtualbox and Vagrantare installed.TECHITO: Drupal. Architecture. Integration. Performance. 11. Getting set upAdd a Vagrant boxCreate the VMConfigure the VMSet up your project environmentTECHITO: Drupal. Architecture. Integration. Performance. 12. Adding a box* *Whats a box? Well cover that shortly.TECHITO: Drupal. Architecture. Integration. Performance. 13. Setting up Ubuntu Precise vagrant box add ubuntu-precise http://cloud- images.ubuntu.com/precise/curren t/precise-server-cloudimg- vagrant-i386-disk1.box vagrant init ubuntu-precise vagrant upTECHITO: Drupal. Architecture. Integration. Performance. 14. Adding the box vagrant box add ubuntu-precise http://cloud- images.ubuntu.com/precise/curren t/precise-server-cloudimg- vagrant-i386-disk1.boxTECHITO: Drupal. Architecture. Integration. Performance. 15. Adding the box vagrant box add ubuntu-precise http://cloud- images.ubuntu.com/precise/curren t/precise-server-cloudimg- vagrant-i386-disk1.boxTECHITO: Drupal. Architecture. Integration. Performance. 16. Adding the box vagrant box add ubuntu-precise http://cloud- images.ubuntu.com/precise/curren 385 MB. t/precise-server-cloudimg- vagrant-i386-disk1.box boxes are Most 350 500MB.TECHITO: Drupal. Architecture. Integration. Performance. 17. Adding the boxTECHITO: Drupal. Architecture. Integration. Performance. 18. Getting set upAdd a Vagrant boxCreate the VMConfigure the VMSet up your project environmentTECHITO: Drupal. Architecture. Integration. Performance. 19. Start with a working dir. mkdir p ~/Development/awesome_project cd ~/Development/awesome_projectTECHITO: Drupal. Architecture. Integration. Performance. 20. Initialise the Vagrant setup vagrant init ubuntu-preciseTECHITO: Drupal. Architecture. Integration. Performance. 21. Launch the Vagrant VM vagrant upTECHITO: Drupal. Architecture. Integration. Performance. 22. Launch the Vagrant VM vagrant upYour vagrant VM is builtand ready to use.TECHITO: Drupal. Architecture. Integration. Performance. 23. Getting set upAdd a Vagrant boxCreate the VMConfigure the VMSet up your project environmentTECHITO: Drupal. Architecture. Integration. Performance. 24. SSH to the VM vagrant sshTECHITO: Drupal. Architecture. Integration. Performance. 25. Install all the things! sudo apt-get install curl apache2 avahi-daemon avahi-discover avahi-utils gcc git-core libapache2-mod-dnssd make mysql-serversamba subversion unzip vim php5 php-apc php5-cli php5-curl php5-dev php5-gd php5-memcachephp5-memcached php5-mysqlnd php5-xdebug These arent all essential, but make a goodbase for a good development environment.TECHITO: Drupal. Architecture. Integration. Performance. 26. Install all the things! sudo apt-get install curl apache2 avahi-daemon avahi-discover avahi-utils gcc git-core libapache2-mod-dnssd make mysql-serversamba subversion unzip vim php5 php-apc php5-cli php5-curl php5-dev php5-gd php5-memcachephp5-memcached php5-mysqlnd php5-xdebugTECHITO: Drupal. Architecture. Integration. Performance. 27. Getting set upAdd a Vagrant boxCreate the VMConfigure the VMSet up your project environmentTECHITO: Drupal. Architecture. Integration. Performance. 28. Create a Drupal setup sudo mkdir /srv/awesome_project sudo chown vagrant:vagrant/srv/awesome_project cd /srv/awesome_project git clonegit@github.com/example/awesome_project.githtdocs mkdir /srv/awesome_project/conf touch /srv/awesome_project/conf/httpd.conf sudo ln s/srv/awesome_project/conf/httpd.conf/etc/apache2/sites-available/awesome_project.conf sudo ln s ../sites-available/awesome_project.conf/etc/apache2/sites-enabledTECHITO: Drupal. Architecture. Integration. Performance. 29. Set up your environment mysql e GRANT ALL ON *.* TOvagrant@localhost IDENTIFIED BY WITH GRANT OPTION Add whichever setup instructions areappropriate for your environmentTECHITO: Drupal. Architecture. Integration. Performance. 30. ManualsetupMANUAL SETUP IS BAAD, MMKAY?TECHITO: Drupal. Architecture. Integration. Performance. 31. STREAMLINING THE SETUPManual installation is never efficientTECHITO: Drupal. Architecture. Integration. Performance. 32. A stream-lined setupOption 1 A magick box.TECHITO: Drupal. Architecture. Integration. Performance. 33. Start with a customised box vagrant box add awesome_project http://boxes.example.com/super cool_drupal_project.boxTECHITO: Drupal. Architecture. Integration. Performance. 34. Start with a customised box vagrant box add awesome_project http://boxes.example.com/super cool_drupal_project.box A magick box. Ill explain later!TECHITO: Drupal. Architecture. Integration. Performance. 35. Follow the standard setup mkdir p ~/Development/awesome_project cd ~/Development/awesome_project vagrant init awesome_project vagrant upTECHITO: Drupal. Architecture. Integration. Performance. 36. Connect to the box vagrant sshTECHITO: Drupal. Architecture. Integration. Performance. 37. Verify whats in the box ls /srv/ which drush mysql -e show databases;TECHITO: Drupal. Architecture. Integration. Performance. 38. Verify whats in the box ls /srv/ which drush mysql -e show databases; vagrant@vm-druprecise:~$ ls -l /srv/ total 4 drwxr-xr-x 3 root root 4096 Mar 10 18:28 foo.localTECHITO: Drupal. Architecture. Integration. Performance. 39. Verify whats in the box ls /srv/ which drush mysql -e show databases; vagrant@vm-druprecise:~$ which drush /usr/local/bin/drushTECHITO: Drupal. Architecture. Integration. Performance. 40. Verify whats in the box ls /srv/ which drush mysql -e show databases; vagrant@vm-druprecise:~$ mysql -e show databases; +--------------------+ | Database | +--------------------+ | information_schema | | foo_local| | mysql| | performance_schema | | phpmyadmin | +--------------------+TECHITO: Drupal. Architecture. Integration. Performance. 41. Recap of all those steps vagrant box add awesome_project http://boxes.example.com/superco ol_drupal_project.box mkdir p ~/Development/awesome_project cd ~/Development/awesome_project vagrant init awesome_project vagrant upTECHITO: Drupal. Architecture. Integration. Performance. 42. TECHITO: Drupal. Architecture. Integration. Performance. 43. A stream-lined setup Option 2 A vagrant config.TECHITO: Drupal. Architecture. Integration. Performance. 44. Start with a build directory mkdir p ~/Development/awesome_project cd ~/Development/awesome_projectTECHITO: Drupal. Architecture. Integration. Performance. 45. Checkout a Vagrant config git clone git@github.com/Techito/vagrant_d rupal_box.git .TECHITO: Drupal. Architecture. Integration. Performance. 46. Verify the checkout ls -lTECHITO: Drupal. Architecture. Integration. Performance. 47. Verify the checkout ls -l Vagrantfile is requiredTECHITO: Drupal. Architecture. Integration. Performance. 48. Verify the checkout ls -l Puppet/chef setup automates the box provisioningTECHITO: Drupal. Architecture. Integration. Performance. 49. Get Vagrant going vagrant upTECHITO: Drupal. Architecture. Integration. Performance. 50. Connect to the box vagrant sshTECHITO: Drupal. Architecture. Integration. Performance. 51. Verify whats in the box ls /srv/ which drush mysql -e show databases;TECHITO: Drupal. Architecture. Integration. Performance. 52. Verify whats in the box ls /srv/ which drush mysql -e show databases; vagrant@vm-druprecise:~$ ls -l /srv/ total 4 drwxr-xr-x 3 root root 4096 Mar 10 18:28 foo.localTECHITO: Drupal. Architecture. Integration. Performance. 53. Verify whats in the box ls /srv/ which drush mysql -e show databases; vagrant@vm-druprecise:~$ which drush /usr/local/bin/drushTECHITO: Drupal. Architecture. Integration. Performance. 54. Verify whats in the box ls /srv/ which drush mysql -e show databases; vagrant@vm-druprecise:~$ mysql -e show databases; +--------------------+ | Database | +--------------------+ | information_schema | | foo_local| | mysql| | performance_schema | | phpmyadmin | +--------------------+TECHITO: Drupal. Architecture. Integration. Performance. 55. Recap of all those steps mkdir p ~/Development/awesome_project cd ~/Development/awesome_project git clone git@github.com/example/awesome _project.git . vagrant upTECHITO: Drupal. Architecture. Integration. Performance. 56. TECHITO: Drupal. Architecture. Integration. Performance. 57. Automated provisioning= super-quick setupTECHITO: Drupal. Architecture. Integration. Performance. 58. VAGRANT VOCABULARYTECHITO: Drupal. Architecture. Integration. Performance. 59. Vagrant Vocabulary VirtualboxAn application to run "Virtual machines" on yourlaptop/desktop. VagrantAn application that automates the setup of VMs. HostThe lapt