Show Menu

Vagrant Set-Up Cheat Sheet by

Setup vagrant network for ansible

Vagrant Use Commands [Run in Project Directory]

vagrant init
| initia­lizes a new vagran­tfile
vagrant init hashic­orp­/pr­ecise64
| new vagran­tfile based on existing box
vagrant up
vagrant ssh
vagrant suspend
vagrant resume
vagrant halt
vagrant reload
| restarts box w/ new config­uration
vagrant destroy
| destroys current endpoint not the base box
vagrant --version

Vagrant Share/­Remote Access

vagrant share
| share your enviro­nment with anyone
vagrant connect
| connect to a shared end point
vagrant hosts
| all hostnames managed by plugin
vagrant hostma­nager
| manages /etc/hosts within a multi machine enviro­nment
vagrant ssh-config
| provides connect config for machine
vagrant rdp
| connects to other machine via rdp


vagran­t.c­onf­igure ("2") do |config|
 ­ ­ ­ ­ = "­has­hic­­or­p­/­pr­­eci­se6­4"
 ­ ­ ­ ­  # guest is the VM; host is your computer end
 ­ ­ ­ ­­twork "­for­war­ded­_po­rt", guest: 80,
host: 8080
 ­ ­ ­ ­­ovision :shell, path:
 ­ ­ ­ ­  # path is relative to your Vagran­tfile

By default ./ on your computer is shared as /vagrant on the vm; allowing other to access your VM

Vagrant Setup

Relocate Vagran­t_Home
     from: \user\.va­grant.d
     to: C:\Vag­ran­t_Home
From an Elevated Prompt
setx VAGRAN­T_HOME "­C:­\Vag­ran­t_H­ome­" /M

Create Base Boxes

vagrant provision
vagrant push
| deploys code to a configured destin­ation
vagrant package
| creates a box from a working enviro­nment
| command related to a pe instal­lation

Vagrant Box Mgmt

vagrant box list
| lists all available boxes
vagrant status
| status of current vagrant end point
vagrant global­-status
| status of all vagrant endpoints
vagrant global­-status prune
| status of all boxes; dropping invalid entries
vagrant box remove
| deletes a copied end point
vagrant provision
| forces end point to re-pro­vision
vagrant reload --prov­ision
| restart end point forcing provis­ioning
vagrant provision --debug
| increases verbosity during debug
vagrant up --prov­ision | tee provis­ion.log
vagrant box outdated
| checks for box updates
enable VBGuest auto update


Linux Base Boxes [vagrant box add]
- hashic­orp­/pr­ecise64
- bento/­cen­tos-7
- bento/­ubu­ntu­-16.04
- ubuntu­/tr­usty64

Windows Base Box [vagrant box add]

Vagrant Plugins

vagrant plugin | manages all plugins
vagrant plugin install vagran­t-v­bguest
vagrant plugin install vagran­t-h­ost­manager
  - manages /etc/hosts within a multi machine enviro­nment
vagrant plugin install vagran­t-env

Vagrant Logs

vagrant up --prov­ision | tee provis­ion.log
forces provis­ioning and writes a log
vagran­t_l­og=info vagrant up
use env var VAGRAN­T_LOG to set verbosity

Customize the Vagran­tfile

Configure Base Boxes
Vagran­t.c­onf­igu­re(­"­2") do |config|
 ­ ­ = "­has­hic­orp­/pr­eci­se6­4" end
Set base box with version number
Vagran­t.c­onf­igu­re(­"­2") do |config|
 ­ ­ = "­has­hic­orp­/pr­eci­se6­4"
 ­ ­­x_v­ersion = "1.1.0"
via url
Vagran­t.c­onf­igu­re(­"­2") do |config|
 ­ ­ = "­has­hic­orp­/pr­eci­se6­4"
 ­ ­­x_url = "­htt­ps:­//v­agr­ant­clo­ud.c­om­/ha­shi­cor­p/p­rec­ise­64"
 ­ ­   


No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Vagrant Cheat Sheet Cheat Sheet