$30 off During Our Annual Pro Sale. View Details »

Virtualize your stack with Vagrant and Puppet

Virtualize your stack with Vagrant and Puppet

An introduction to the how and why of Vagrant and Puppet.

Find out more at http://jmather.com/talks/2013-05-25/

Jacob Mather

May 25, 2013
Tweet

More Decks by Jacob Mather

Other Decks in Technology

Transcript

  1. Virtualize  your  stack  with  
    Vagrant  and  Puppet  
    Jacob  Mather  
    So;ware  Engineer,  Mashery  

    View Slide

  2. Vagrant  

    View Slide

  3. What  is  Vagrant?  
    A  tool  that  allows  you  to  create  and  configure  
    lightweight,  reproducible,  and  portable  
    development  environments.  

    View Slide

  4. Vagrant  is  built…  
    •  To  be  simple  
    •  In  Ruby  

    View Slide

  5. How  to  use  Vagrant  
    •  Install  Vagrant  (hKp://vagrantup.com)  
    •  Check  out  your  repository  
    •  Run:  vagrant  up  

    View Slide

  6. Vagrant  Terms  
    •  Box  –  Also  called  base  box,  is  the  base  image  
    •  Guest  –  Refers  to  an  individual  vm  

    View Slide

  7. Vagrant  Providers  
    Vagrant  can  use  a  few  different  plaVorms  for  
    spinning  up  new  servers.  Currently,  they  are:  
     
    •  VirtualBox  (hKps://www.virtualbox.org/)  
    •  *VMware  (Fusion  and  WorkstaYon)  
    VagrantUp.com  pushes  for  VMware  for  “work”  

    View Slide

  8. Vagrant  Providers  (cont…)  
    •  VirtualBox  is  FREE!  
    – It  works  great  except  where  it  doesn’t  
    •  Some  people  have  trouble  with  it  crashing  
    •  It  can’t  handle  a  large  number  of  files  with  the  standard  
    file  sharing  system  
    •  NFS  poses  it’s  own  complicaYons  
    •  Vmware  is  PAID!  
    – It’s  $49  or  $99  for  the  so;ware  and  $79  for  the  
    provider  
    – Supposed  to  be  more  stable  and  faster  

    View Slide

  9. Basic  Vagrant  Commands  
    •  vagrant  up  –  Turn  guest  on  
    •  vagrant  halt  –  Turn  guest  off  
    •  vagrant  status  –  Show  guest  status  
    •  vagrant  destroy  –  Delete  guest  
    •  vagrant  suspend  –  Suspend  guest  
    •  vagrant  resume  –  Resume  guest  
    •  vagrant  ssh  –  SSH  into  guest  

    View Slide

  10. Basic  VagranVile  
    Vagrant.configure("2")  do  |config|  
       config.vm.box  =  "base-­‐box-­‐name"    
       config.vm.box_url  =  ”hKp://some/url.box"  
    end  

    View Slide

  11. Basic  VagranVile  (with  FS)  
    Vagrant.configure("2")  do  |config|  
       config.vm.box  =  "base-­‐box-­‐name"    
       config.vm.box_url  =  ”hKp://some/url.box"  
       config.vm.synced_folder  "/data",  "/vagrant_data"  
    end  

    View Slide

  12. Basic  VagranVile  (and  PF)  
    Vagrant.configure("2")  do  |config|  
       config.vm.box  =  "base-­‐box-­‐name"  
       config.vm.box_url  =  "hKp://some/url.box"  
       config.vm.network  :forwarded_port,  guest:  80,  host:  8080  
       config.vm.synced_folder  "/data",  "/vagrant_data"  
    end  

    View Slide

  13. Basic  MulY-­‐Guest  VagranVile  
    nodes  =  {        
       :'webserver'  =>  {  
           :hostname  =>  'server.example.com',  
           :ipaddress  =>  '192.168.56.60',  
       },  
       :'dbserver'  =>  {  
           :hostname  =>  'db.example.com',  
           :ipaddress  =>  '192.168.56.61',  
       }  
    }  

    View Slide

  14. Basic  MulY-­‐Guest  VagranVile  
    nodes  =  {  …  node  configuraYon  …  }  
    Vagrant.configure("2")  do  |config|  
       nodes.each_pair  do  |name,opYons|  
           config.vm.define  name  do  |node|  
               node.vm.box  =  "base-­‐box-­‐name"  
               node.vm.box_url  =  "hKp://some/url.box"  
               node.vm.hostname  =  opYons[:hostname]  
               node.vm.network  :private_network,  ip:  opYons[:ipaddress]  
           end  
       end  
    end  
     

    View Slide

  15. Vagrant  Limits  
    So  this  whole  spinning  up  guests  thing  is  cool  
    and  all,  but  what  am  I  supposed  to  do  with  all  of  
    these  dumb  boxes?  
     
    “Hardware”  without  so;ware  is  nearly  useless.  

    View Slide

  16. Vagrant  Provisioning  
    •  Shell  Scripts  
    •  Ansible  
    •  Chef  (Solo  and  Client)  
    •  Puppet  (Apply  and  Agent)  

    View Slide

  17. Puppet  

    View Slide

  18. What  is  Puppet?  
    Puppet  is  IT  automaYon  so;ware  that  helps  
    system  administrators  manage  infrastructure  
    throughout  its  lifecycle,  from  provisioning  and  
    configuraYon  to  patch  management  and  
    compliance.  

    View Slide

  19. I  have  no  idea  what  that  means.  

    View Slide

  20. What  is  Puppet?  
    Puppet  gives  you  an  “object  oriented”  way  to  
    manage  the  configuraYon  of  your  servers,  either  
    on  your  laptop,  in  the  cloud,  or  in  your  favorite  
    data  center.  

    View Slide

  21. Puppet  is  built…  
    •  To  be  simple  
    •  With  it’s  own  configuraYon  language  

    View Slide

  22. Puppet  Terms  
    •  Manifests  –  EssenYally  instrucYons  
    •  Modules  –  Abstracted  manifests  
    •  Templates  –  Exactly  as  it  sounds  
    •  Facter  –  Variable  manager  
    •  Hiera  –  ConfiguraYon  management  

    View Slide

  23. How  to  use  Puppet?  
    Use  a  base  box  for  Vagrant  from  Puppet  Labs  
     
    hKp://puppet-­‐vagrant-­‐boxes.puppetlabs.com/  
     
    I  like  to  use  the  CentOS  6.4  for  VirtualBox  
     

    View Slide

  24. Basic  Puppet  Powered  VagranVile  
    Vagrant.configure("2")  do  |config|  
       config.vm.box  =  "base-­‐box-­‐name"  
       config.vm.box_url  =  "hKp://some/url.box"  
       config.vm.provision  :puppet  do  |puppet|  
           puppet.manifests_path  =  "puppet/manifests/"  
           puppet.manifest_file    =  "guest.pp"  
           puppet.module_path  =  "puppet/modules/"  
       end  
    end  

    View Slide

  25. Vagrant  and  Puppet  

    View Slide

  26. Other  Resources  
    hKp://PuPHPet.com  
     
    PuPHPet  provides  a  
    simple  config  tool  for  
    those  who  don’t  want  
    to  Ynker  with  puppet  
    and  need  a  LAMP  stack  
    up  and  running  NOW.  

    View Slide

  27. Thank  you!  
    More  informaYon  can  be  found  at:  
     
    hKp://jmather.com/talks/2013-­‐05-­‐25  
     

    View Slide