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

Vagrant 101 - Hack&Beers HMO

Vagrant 101 - Hack&Beers HMO

Charla introductoria a Vagrant dada en Hack&Beers Hermosillo

Eduardo Urias

May 17, 2013
Tweet

More Decks by Eduardo Urias

Other Decks in Technology

Transcript

  1. Eduardo Urias Founder @ Inspect Labs Engineer @ Threat Stack

    Long Time Hack&Beers Contributor @larsx2 whoami
  2. What is Vagrant? “Vagrant is a tool for building complete

    development environments. With an easy-to- use workflow and focus on automation, lowers development environment setup time, increases development/production parity, and makes the ‘works on my machine’ a relic from the past”
  3. • Creates one or more VMs based on the OS

    of your choice • Modifies properties of the VM (RAM, CPU, etc) • Establish network interfaces so that you can access • Sets up shared folders between Host and Guest • Manages running VMs for pause, resume, destroy, halt, etc. • Provisions software on the machine(s) via shell scripts or configuration management tools like Ansible, Chef, Puppet, Salt, etc. • Integrate with different Virtualization Providers like VirtualBox, VMWare($) and even Cloud Providers like Digital Ocean, Amazon EC2, Rackspace, etc. What does Vagrant really do?
  4. What will we learn? • Basic Configurations • Common operations

    (up, halt, resume, etc) • Boxes • Networking • Synced Folders • Basic Provisioning
  5. Vagrantfile • Describes the type of the machine required for

    a project and how to configure said machine. • The syntax of the file is Ruby (DSL) • Vagrantfile is meant to be used per environment and should be placed in its own directory per use case • The vagrant command uses this file to acquire information about the running VMs
  6. Synced Folders “Synced folders enable Vagrant to sync a folder

    on the host machine to the guest machine, allowing you to continue working on your project's files on your host machine, but use the resources in the guest machine to compile or run your project.” This line will enable the “code-examples” directory in the current machine to be “mirrored” to “/opt/code-examples” in the Guest VM. This will allow us to work using our IDE’s or Development settings in our dev machine and running the application/scripts in the VM.
  7. “They are portable files which can be used by others

    on any platform that runs Vagrant to bring up a working environment.” Building VMs from scratch is resource-intensive and time-consuming Vagrant uses base images and clones them on demand Base images are distributed as “box” files. Boxes contains pre-installed operating systems ranging from MB’s to GB’s. Boxes are shared between multiple Vagrant environments (Vagrantfiles) Boxes
  8. Kick Ass Feature ALERT $ vagrant package --output new_updated.box This

    command takes the current RUNNING VM and makes a portable box that can be added (through “box add”). Excellent for updating existing boxes or ship with other goodies that will be a pain to wait on a provision.
  9. Plugins Plugins allows the ability to change how Vagrant does

    certain stuff or enable additional functionality. Some examples of useful plugins are: • vagrant-omnibus and vagrant-berkshelf (chef) • vagrant-digital_ocean • vagrant-aws • vagrant-rackspace
  10. Let’s say you plan to give an algorithms class and

    want to provide an Ubuntu 12.04 updated image with vim, git and the algorithms code examples shipped in it. https://github.com/larsx2/hacknbeers-vagrant-examples/tree/master/cases/algo-class Use Case #1
  11. Ubuntu 12.04 LTS Apache, PHP Sync Folder “code” to “/var/www/code”

    Set Private Network Address to 192.168.33.11 https://github.com/larsx2/hacknbeers-vagrant-examples/tree/master/cases/lamp-env Use Case #2