Show Menu

Vagrant Set-Up Cheat Sheet by

Setup vagrant network for ansible

Vagrant Setup

Vagrant installs at c:\has­hic­orp­\va­grant
Vagran­tfile is located at c:\users\ users name \vagra­ntfile
Hyper-V & Virtual Box cannot run simult­ane­ous­ly

Initial Config­uration

vagrant init [Init­ializes new vagran­tfile]
vagrant init hashic­­or­p­/­pr­­eci­se64
Only 1 vagran­tfile can exist
rm vagran­tfile [deletes vagran­tfile]
rm vagrant hashic­orp­/pr­­ec­ise­64

General Info & Day-to-Day Mainte­nance

vagrant box list
[all available vagrant boxes on this endpoint]
vagrant status
[status of current vagrant endpoint]
vagrant box outdated
[checks for box updates]
vagrant global­-st­atus
i.e. c:\use­rs­\msm­ith­097­>
id name provider state directory
b2bcba9 default hyperv running C:/has­hic­orp­/Va­grant
a226748 default hyperv running C:/Use­rs/­msm­ith097

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

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

Website Resources


Advanced Vagrant Box Mgmt

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
enable VBGuest auto update
vagrant global­-st­atus [displays status for all endpoi­nts]
PS C:\Use­rs­\msm­ith­097> vagrant global­-status
id name provider state directory ------­---­---­---­---­---­---­---­---­---­---­---­---­---­---­---­---­---­---­---­------- b2bcba9 default hyperv running C:/has­hic­orp­/Va­grant a226748 default hyperv running C:/Use­rs/­msm­ith097

Vagrant Base Boxes [standard templates]

$ vagrant box add {title} or {url}

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

Windows Base Box [vagrant box add]

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