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

Vagrant Up!

Vagrant Up!

Talk from DevObjective 2015

Kyle Boon

May 15, 2015
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 p r e c i s e 6 4 $ v a g r a n t u p
  2. Boxes Template used to start a virtual machine You can

    create your own https://vagrantcloud.com/ http://www.vagrantbox.es/
  3. # - * - m o d e : r

    u b y - * - # v i : s e t f t = r u b y : # A l l V a g r a n t c o n f i g u r a t i o n i s d o n e b e l o w . T h e " 2 " i n V a g r a n t . c o n f i g u r e # c o n f i g u r e s t h e c o n f i g u r a t i o n v e r s i o n ( w e s u p p o r t o l d e r s t y l e s f o r # b a c k w a r d s c o m p a t i b i l i t y ) . P l e a s e d o n ' t c h a n g e i t 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 . c o n f i g u r e ( 2 ) d o | c o n f i g | # T h e m o s t c o m m o n c o n f i g u r a t i o n o p t i o n s a r e d o c u m e n t e d a n d c o m m e n t e d b e l o w . # F o r a c o m p l e t e r e f e r e n c e , p l e a s e s e e t h e o n l i n e d o c u m e n t a t i o n a t # h t t p s : / / d o c s . v a g r a n t u p . c o m . # E v e r y V a g r a n t d e v e l o p m e n t e n v i r o n m e n t r e q u i r e s a b o x . Y o u c a n s e a r c h f o r # b o x e s a t h t t p s : / / a t l a s . h a s h i c o r p . c o m / s e a r c h . c o n f i g . v m . b o x = " p r e c i s e 6 4 " e n d
  4. Vagrant CLI 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
  5. 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
  6. 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 "
  7. 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
  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 " 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
  9. 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
  10. 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
  11. v a g r a n t u p -

    - p r o v i d e r = d o c k e r