Getting started with Vagrant

Getting started with Vagrant

Presented at BADCamp 2014

243a67c0999a78012ca6979a64ada096?s=128

Alina Mackenzie

November 09, 2014
Tweet

Transcript

  1. 2.
  2. 3.

    ABOUT YOU new to Drupal? developer or site builder? Drupal

    core or contrib developer? curious about Vagrant?
  3. 4.

    STARTING POINT MAMP (Mac, Windows) environment is not like production

    can't automate not good for multiple projects good starting point
  4. 6.

    WHAT IS VAGRANT? Vagrant is a tool for building complete

    development environments. set of Ruby scripts set of commands "remote control" that works with virtualization platforms (VirtualBox, VMWare) and automation tools (shell, Chef, Ansible)
  5. 9.

    HOST AND GUEST Host - your laptop or desktop Guest

    - virtual machine started on the host
  6. 10.

    BOX A box is a bundle containing an installed operating

    system (and some basic stuff) made for a specific provider (VirtualBox). Package manager SSH server SSH user so Vagrant can connect Get boxes from , , etc. vagrantcloud.com vagrantbox.es
  7. 12.

    PROVISIONER A provisioner will automate the setup of your server,

    installing packages and performing tasks in general. shell Ansible Puppet Chef Docker Salt
  8. 13.

    VAGRANTFILE Configuration file for your Vagrant guest. V a g

    r a n t . c o n f i g u r e ( " 2 " ) d o | c o n f i g | c o n f i g . v m . b o x = " u b u n t u / t r u s t y 6 4 " e n d
  9. 14.
  10. 15.

    SHARED/SYNCED FOLDERS With a shared folder, you can edit your

    files with your favorite editor installed on the Host machine.
  11. 16.

    SIMPLE EXAMPLE Vagrantfile: V a g r a n t

    . c o n f i g u r e ( " 2 " ) d o | c o n f i g | c o n f i g . v m . b o x = " u b u n t u / t r u s t y 6 4 " c o n f i g . v m . n e t w o r k " p u b l i c _ n e t w o r k " , i p : " 1 9 2 . 1 6 8 . 0 . 1 7 " c o n f i g . v m . s y n c e d _ f o l d e r " w w w " , " / v a r / w w w / h t m l " , t y p e : " n f s " e n d
  12. 18.

    VAGRANT COMMANDS vagrant status vagrant global-status vagrant up vagrant ssh

    vagrant reload vagrant provision vagrant init vagrant halt vagrant destroy vagrant suspend vagrant resume
  13. 19.
  14. 20.

    MORE COMPLEX EXAMPLE Vagrantfile: V a g r a n

    t . c o n f i g u r e ( " 2 " ) d o | c o n f i g | c o n f i g . v m . b o x = " u b u n t u / t r u s t y 6 4 " c o n f i g . v m . n e t w o r k " p r i v a t e _ n e t w o r k " , t y p e : " d h c p " c o n f i g . v m . s y n c e d _ f o l d e r " w w w " , " / v a r / w w w / h t m l " , t y p e : " n f s " c o n f i g . v m . p r o v i d e r " v i r t u a l b o x " d o | v b | v b . m e m o r y = " 1 0 2 4 " e n d c o n f i g . v m . p r o v i s i o n " s h e l l " d o | s | s . p a t h = " d 8 - p r o v i s i o n . s h " e n d e n d
  15. 21.

    PROVISIONING STEPS Update package manager (apt) Install development tools: git,

    curl, vim Install web server (Apache) Install database (MySQL) Install PHP Install Composer (PHP package manager) Install Drush using Composer Use Drush or git to download Drupal 8 Use Drush to install Drupal 8
  16. 22.

    COMMANDS d8-provision.sh sudo apt-get update sudo apt-get install git curl

    vim sudo apt-get install apache2 sudo apt-get install mysql-server sudo apt-get install php5 curl -sS https://getcomposer.org/installer | php composer global require drush/drush:dev-master drush dl drupal-8 git clone --branch 8.0.x http://git.drupal.org/project/drupal.git drush site-install --account-pass=admin --db-url=mysql://root:root@localhost/d8
  17. 24.

    VAGRANT UP B r i n g i n g

    m a c h i n e ' d e f a u l t ' u p w i t h ' v i r t u a l b o x ' p r o v i d e r . . . = = > d e f a u l t : I m p o r t i n g b a s e b o x ' u b u n t u / t r u s t y 6 4 ' . . . = = > d e f a u l t : M a t c h i n g M A C a d d r e s s f o r N A T n e t w o r k i n g . . . = = > d e f a u l t : C h e c k i n g i f b o x ' u b u n t u / t r u s t y 6 4 ' i s u p t o d a t e . . . = = > d e f a u l t : S e t t i n g t h e n a m e o f t h e V M : t r u s t y - d 8 = = > d e f a u l t : C l e a r i n g a n y p r e v i o u s l y s e t f o r w a r d e d p o r t s . . . = = > d e f a u l t : C l e a r i n g a n y p r e v i o u s l y s e t n e t w o r k i n t e r f a c e s . . . = = > d e f a u l t : P r e p a r i n g n e t w o r k i n t e r f a c e s b a s e d o n c o n f i g u r a t i o n . . . d e f a u l t : A d a p t e r 1 : n a t d e f a u l t : A d a p t e r 2 : h o s t o n l y = = > d e f a u l t : F o r w a r d i n g p o r t s . . . d e f a u l t : 2 2 = > 2 2 2 2 ( a d a p t e r 1 ) = = > d e f a u l t : R u n n i n g ' p r e - b o o t ' V M c u s t o m i z a t i o n s . . . = = > d e f a u l t : B o o t i n g V M . . . = = > d e f a u l t : W a i t i n g f o r m a c h i n e t o b o o t . T h i s m a y t a k e a f e w m i n u t e s . . . d e f a u l t : S S H a d d r e s s : 1 2 7 . 0 . 0 . 1 : 2 2 2 2 d e f a u l t : S S H u s e r n a m e : v a g r a n t d e f a u l t : S S H a u t h m e t h o d : p r i v a t e k e y d e f a u l t : W a r n i n g : C o n n e c t i o n t i m e o u t . R e t r y i n g . . . d e f a u l t : W a r n i n g : R e m o t e c o n n e c t i o n d i s c o n n e c t . R e t r y i n g . . . = = > d e f a u l t : M a c h i n e b o o t e d a n d r e a d y ! G u e s t A d d i t i o n s v e r s i o n s o n y o u r h o s t ( 4 . 3 . 1 8 ) a n d g u e s t ( 4 . 3 . 1 0 ) d o n o t m a t c h . * S t o p p i n g V i r t u a l B o x A d d i t i o n s . . . d o n e . R e a d i n g p a c k a g e l i s t s . . . B u i l d i n g d e p e n d e n c y t r e e . . . R e a d i n g s t a t e i n f o r m a t i o n . . . T h e f o l l o w i n g p a c k a g e s w e r e a u t o m a t i c a l l y i n s t a l l e d a n d a r e n o l o n g e r r e q u i r e d : d k m s f a k e r o o t g c c g c c - 4 . 8 l i b a s a n 0 l i b a t o m i c 1 l i b c - d e v - b i n l i b c 6 - d e v About 8 minutes to a fully installed Drupal site
  18. 25.
  19. 26.
  20. 27.

    PLUGINS vbguest automatically installs the host's VirtualBox Guest Additions on

    the guest system vagrant plugin install vagrant-vbguest
  21. 28.

    TIPS red doesn't always mean error vagrant version to check

    for updates (not vagrant --version) vagrant global-status to see all VM on the host vagrant global-status --prune if you delete a directory with a running VM sudo rm /etc/exports if you rename your VM directory edit /etc/sudoers to avoid being prompted for administrator password