Do less plumbing by using Vagrant
Vagrant makes managing a virtual machine’s (VMs) lifecycle easy by providing simple commands. It lets developers focus on developing rather than plumbing work. Below is a high-level overview of Vagrant with links for further reading.
- standardization - configure once, use everywhere
- windows
- If you need rsync then go with
- Cygwin
- MinGW
- otherwise can make do with
- putty
- If you need rsync then go with
- mac
- linux
- windows
-
reduces overhead - manage VM lifecycle with commands
vagrant up vagrant suspend vagrant halt vagrant destroy vagrant reload vagrant status vagrant init vagrant box list vagrant box remove <name-of-box> vagrant box add <name-of-box> vagrant ssh vagrant provision
- wide support
- out of the box support for the following providers
- VirtualBox
- Hyper-V
- compatible with Windows 8.1 only
- must turn it on as a windows feature
- Docker
- VMWare
- remote clouds
- AWS EC2
- Rackspace
- provisioning tools
- shell scripts
- ideal for new users who want to get up and running quickly
- Ansible
- Chef
- vagrant does not automatically install provisioners for chef and puppet
- need to install it in the base box
- Puppet
- vagrant does not automatically install provisioners for chef and puppet
- need to install it in the base box
- can use to install services like
- databases
- web servers
- Salt
- Docker
- automatically installs Docker
- can use puppet (installing services) + docker (contain your application) provisioner together
- shell scripts
- out of the box support for the following providers
- share - easy to distribute VMs
- share box file
- you can upload to HashiCorp’s Atlas
- share via any other means
- share vagrant
- share your vagrant environment
- SSH sharing
- remote into your vagrant box
- HTTP sharing
- share your webserver links to clients for feedback
- SSH sharing
- share your vagrant environment
- share box file
- provides high-level interface to simplify working with VMs
- synced folders
- automatically sync files to and from guest machines
/vagrant
is the shared directory
- provisioning
- automatically install software during
vagrant up
phase - use configuration (a.k.a provisioning) tools to automate installation
- specify configuration using
vagrantfile
- automatically install software during
- networking
- exposes high-level networking interface to help you
- forward ports
- connecting to a public network
- creating a private network
- exposes high-level networking interface to help you
- synced folders
Steps for getting started with Vagrant
Testing a Box
vagrant box add my-box /path/to/the/new.box
vagrant init my-box
vagrant up
Vagrant Push
- deploy code residing in same directory as vagrant file to a remote server
- through
- SFTP
- Local Exec
- your own rsync script
Terms
- file to describe how to configure and provision machines
- specifies type of machine required for project
- uses ruby syntax
- ruby knowledge not required, just simple variable assignments
- portable
- the base image of a virtual machine
- can be downloaded from a local file, custom URL or HashiCorp’s Atlas Box Catalog
- contains the bare minimum for vagrant to function
- used as a clean starting point for building new environments
- are provider specific
- contains two components
- Box File
- required
- compressed (tar, tar.gz, zip)
- specific to a single provider (eg. VirtualBox)
- Box Catalog Metadata
- optional but recommended
- JSON document
- provide support for multiple providers and versioning
- Box File
- free public boxes available for download
- lets you host your own public or private boxes
- benefits
- support for versioning, pushing updates, analytics and more
- benefits
- lets you automate installation software
- and alter configuration