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

Vagrant Up

Vagrant Up

Vagrant is a tool to create and configure development environments in a virtual machine. I'll go over the basics of vagrant plus orchestration tools like chef. I'll also show how Bloom Health uses Vagrant to help developers cope with our growing services based stack. These tools allow developers to focus on writing business logic and not worry about mysql versions and other minutiae.

Kyle Boon

April 05, 2014
Tweet

More Decks by Kyle Boon

Other Decks in Programming

Transcript

  1. Your first Vagrant image $ v a g r a

    n t i n i t h a s h i c o r p / p r e c i s e 3 2 $ v a g r a n t u p
  2. # - * - m o d e : r

    u b y - * - # v i : s e t f t = r u b y : # V a g r a n t f i l e A P I / s y n t a x v e r s i o n . D o n ' t t o u c h u n l e s s y o u k n o w w h a t y o u ' r e d o i n g ! V A G R A N T F I L E _ A P I _ V E R S I O N = " 2 " V a g r a n t . c o n f i g u r e ( V A G R A N T F I L E _ A P I _ V E R S I O N ) d o | c o n f i g | c o n f i g . v m . b o x = " h a s h i c o r p / p r e c i s e 3 2 " e n d
  3. Main Commands box manages boxes: installation, removal, etc. destroy stops

    and deletes all traces of the vagrant machine halt stops the vagrant machine init initializes a new Vagrant environment by creating a Vagrantfile plugin manages plugins: install, uninstall, update, etc. provision provisions the vagrant machine reload restarts vagrant machine, loads new Vagrantfile configuration resume resume a suspended vagrant machine ssh connects to machine via SSH suspend suspends the machine up starts and provisions the vagrant environment
  4. Configuring providers 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 . c u s t o m i z e [ " m o d i f y v m " , : i d , " - - n a t d n s h o s t r e s o l v e r 1 " , " o n " ] v b . c u s t o m i z e [ " m o d i f y v m " , : i d , " - - m e m o r y " , m e m _ s i z e ? m e m _ s i z e : 6 6 0 8 ] v b . c u s t o m i z e [ " m o d i f y v m " , : i d , " - - c p u s " , n u m _ c p u s ? n u m _ c p u s : 2 ] e n d
  5. Syncing Folders c o n f i g . v

    m . s y n c e d _ f o l d e r F i l e . e x p a n d _ p a t h ( " . . / " ) , " / p r e s e n t a t i o n "
  6. Netorking Support for forwarded ports, public and private networks etc

    c o n f i g . v m . n e t w o r k " f o r w a r d e d _ p o r t " , g u e s t : 8 0 , h o s t : 8 0 8 0
  7. 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 . p r o v i s i o n " s h e l l " , i n l i n e : " e c h o H e l l o " c o n f i g . v m . d e f i n e " w e b " d o | w e b | w e b . v m . b o x = " a p a c h e " e n d c o n f i g . v m . d e f i n e " d b " d o | d b | d b . v m . b o x = " m y s q l " e n d e n d
  8. 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 . p r o v i s i o n " s h e l l " , i n l i n e : " e c h o H e l l o , W o r l d " e n d
  9. c o n f i g . v m .

    p r o v i s i o n : c h e f _ s o l o d o | c h e f | c h e f . j s o n = { : j a v a = > { : i n s t a l l _ f l a v o r = > " o r a c l e " , : j d k _ v e r s i o n = > " 7 " , : o r a c l e = > { " a c c e p t _ o r a c l e _ d o w n l o a d _ t e r m s " = > t r u e } } } c h e f . r u n _ l i s t = [ " r e c i p e [ a p t ] " , " r e c i p e [ g i t ] " , " r e c i p e [ j a v a ] " , " r e c i p e [ m o n g o d b : : 1 0 g e n _ r e p o ] " , " r e c i p e [ m o n g o d b ] " , " r e c i p e [ v e r t x ] " ] e n d