Vagrant is a command-line interface for simplifying the use of virtual machines (VM's). Vagrant allows teams to standardize their software development workflows by offering a uniform and portable interface to provision and run VM's on different operating platforms such as Mac OS X, Windows, and Linux and achieve identical results. It supports all the major virtualization solutions such as VirtualBox, VMWare, and Hyper-V and supports configuration tools that range from simple shell scripts to powerful Chef and Puppet recipes. Developers simply invoke “vagrant up” and immediately enjoy a standard, consistent, and reproducible VM for software development and testing.
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
Vagrant for Software Development
1. It Works on My Machine:It Works on My Machine:
Vagrant for Software DevelopmentVagrant for Software Development
Colorado Springs Open Source Software MeetupColorado Springs Open Source Software Meetup
1/20/20161/20/2016
Carlos PerezCarlos Perez
perez@doorstep.comperez@doorstep.com
2. January 20, 2016 Overview of Vagrant 2
Traditional Dev. EnvironmentTraditional Dev. Environment
SCM / CI
Dev. 1 w/ app stack
Mac OS X
Test / Stage /Prod
Dev. 2 w/ app stack
Linux Ubuntu
Dev. 3 w/ app stack
MS Windows
Dev. 4 w/ app stack
Everyone has their own application stack
and machine dependencies. This is known
as the 'works on my machine' problem.
3. January 20, 2016 Overview of Vagrant 3
Source: TIOBE Index for January 2016
http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html
TIOBE Index of Popular Programming Languages
4. January 20, 2016 Overview of Vagrant 4
Why Use Vagrant?Why Use Vagrant?
●
SOLUTION: Have everyone work on the 'sameSOLUTION: Have everyone work on the 'same
machine' bymachine' by declaratively specifying thedeclaratively specifying the
configuration for a VM instanceconfiguration for a VM instance
●
Based on virtual machines you already knowBased on virtual machines you already know
(VirtualBox, VMWare, Hyper-V, etc.)(VirtualBox, VMWare, Hyper-V, etc.)
●
Easy to configure, reproducible, portableEasy to configure, reproducible, portable
●
SCM friendly files (git, tfvc)SCM friendly files (git, tfvc)
●
DevOps friendly: write and test provisioningDevOps friendly: write and test provisioning
'scripts' (Chef, Puppet, Ansible, etc.)'scripts' (Chef, Puppet, Ansible, etc.)
5. January 20, 2016 Overview of Vagrant 5
Vagrant ArchitectureVagrant Architecture
VM
Host OS
Guest OS: CentOS
/home/user1/projects/web1 => /vagrant
Web Browser
IDE / Editor
git
Apache
PHP
MySQL
port 2222 => 22; port 8000 => 80
Virtualbox
port forwards
synced folders
7. January 20, 2016 Overview of Vagrant 7
VagrantVagrant
●
Open source, started in 2010 by MitchellOpen source, started in 2010 by Mitchell
HashimotoHashimoto
●
MIT LicenseMIT License
●
Website:Website: https://www.vagrantup.comhttps://www.vagrantup.com
●
Docs:Docs: https://docs.vagrantup.com/v2/https://docs.vagrantup.com/v2/
●
Installation:Installation:
●
Vagrant (apt-get, .deb, .dmg, .msi)Vagrant (apt-get, .deb, .dmg, .msi)
●
VM (VM (https://www.virtualbox.orghttps://www.virtualbox.org))
●
Windows: PuTTY, PuTTYgenWindows: PuTTY, PuTTYgen
8. January 20, 2016 Overview of Vagrant 8
TerminologyTerminology
●
BoxBox: VM base image for: VM base image for guestguest (a.k.a.(a.k.a. templatetemplate))
●
ProviderProvider: virtualization layer on: virtualization layer on hosthost
(VirtualBox, VMWare, etc.)(VirtualBox, VMWare, etc.)
●
ProvisionerProvisioner: system for automating software: system for automating software
installations (shell, chef, etc.)installations (shell, chef, etc.)
●
ProjectProject: directory containing Vagrantfile and: directory containing Vagrantfile and
typically the root of the 'synced folder'typically the root of the 'synced folder'
9. January 20, 2016 Overview of Vagrant 9
Basic CommandsBasic Commands
● vagrant –helpvagrant –help
● vagrant global-statusvagrant global-status: show: show
environmentsenvironments
● vagrant statusvagrant status: show project status: show project status
● vagrant box listvagrant box list: show installed boxes: show installed boxes
10. January 20, 2016 Overview of Vagrant 10
Vagrant Up FlowVagrant Up Flow
A
Box repository
download
B
Local box
directory
C
VM instance
directory
import
1) vagrant up
2) If box does not exist, download from 'A' and add to 'B'
3) If VM does not exist, import from local box directory 'B' and copy to 'C'
4) Start VM, networking, port forwards, import SSH keys
5) Mount shared folders
6) Provision VM
7) vagrant ssh
https://atlas.hashicorp.com/ubuntu/boxes/trusty32/versions/20151218.0.1/
provider/virtualbox.box
~/.vagrant.d/boxes/ubuntu-VAGRANTSLASH-trusty32
~/VirtualBox VMs/trusty32_default_1452718546328_49107
11. January 20, 2016 Overview of Vagrant 11
Where to Find Boxes?Where to Find Boxes?
●
Hashicorp Atlas (Hashicorp Atlas (https://atlas.hashicorp.com/https://atlas.hashicorp.com/))
●
Cataloged using theCataloged using the vendor/boxnamevendor/boxname notationnotation
●
Public catalogs (Public catalogs (http://www.vagrantbox.es/http://www.vagrantbox.es/))
●
Think craigslist-- boxes may not be secureThink craigslist-- boxes may not be secure
● Build your own usingBuild your own using packerpacker oror vagrantvagrant
packagepackage
●
Installation ISO + packer + JSON config = your boxInstallation ISO + packer + JSON config = your box
●
Host on your own web serverHost on your own web server
12. January 20, 2016 Overview of Vagrant 12
Vagrant Lifecycle CommandsVagrant Lifecycle Commands
● vagrant upvagrant up
instantiate, provision,instantiate, provision,
start VMstart VM
● vagrant haltvagrant halt: stop: stop
/ poweroff VM/ poweroff VM
● vagrant destoryvagrant destory::
stop / delete VMstop / delete VM
● vagrant suspendvagrant suspend //
vagrant resumevagrant resume
running
powered
off
suspended
non-
existent
resumesuspend
up
halt
destroy up
13. January 20, 2016 Overview of Vagrant 13
Vagrant SnapshotVagrant Snapshot
●
Vagrant supports VMVagrant supports VM
snapshotssnapshots
● vagrant snapshot pushvagrant snapshot push
// poppop
● vagrant snapshot savevagrant snapshot save
// restorerestore
● vagrant snapshot listvagrant snapshot list
● vagrant snapshotvagrant snapshot
deletedelete
●
Note: do not mixNote: do not mix
push/pop andpush/pop and
save/restoresave/restore
snapshots
VM
instance
push pop
14. January 20, 2016 Overview of Vagrant 14
The VagrantfileThe Vagrantfile
●
Vagrantfile in project controls 'up' processVagrantfile in project controls 'up' process
●
Ruby languageRuby language
●
Located in project directory and checked into SCMLocated in project directory and checked into SCM
● vagrant upvagrant up creates .vagrant directory (add tocreates .vagrant directory (add to
.gitignore).gitignore)
●
Other Vagrantfiles are consulted duringOther Vagrantfiles are consulted during
vagrant upvagrant up (process called 'merging')(process called 'merging')
●
~/.vagrant.d/boxes/.../Vagrantfile, include/_Vagrantfile~/.vagrant.d/boxes/.../Vagrantfile, include/_Vagrantfile
●
~/.vagrant.d~/.vagrant.d
●
Vagrantfile in the project hierarchyVagrantfile in the project hierarchy
15. January 20, 2016 Overview of Vagrant 15
Initializing a ProjectInitializing a Project
$ cd ~/project1
$ vagrant init ubuntu/trusty32
$ vagrant up
16. January 20, 2016 Overview of Vagrant 16
ProvisioningProvisioning
●
ProvisioningProvisioning occursoccurs
after aafter a boxbox isis
importedimported into a VMinto a VM
●
Provisioning usuallyProvisioning usually
occurs once, but canoccurs once, but can
be run againbe run again
● vagrant provisionvagrant provision
●
Vagrantfile config.vm.provisionVagrantfile config.vm.provision
run: 'always', etc.run: 'always', etc.
...
config.vm.provision "shell",
inline: <<-SHELL
sudo apt-get update
sudo apt-get install -y
apache2
SHELL
...
17. January 20, 2016 Overview of Vagrant 17
Types of ProvisionersTypes of Provisioners
Name Description
file The file provisioner allows you to upload a file or directory from the host
machine to the guest machine.
shell The shell provisioner allows you to upload and execute a script within the
guest machine.
ansible,
ansible_local
The Ansible provisioner allows you to provision the guest using Ansible
playbooks by executing ansible-playbook from the Vagrant host; ansible_local
is executed on the guest machine.
cfengine The CFEngine provisioner allows you to provision the guest using CFEngine.
chef_solo,
chef_zero,
chef_client,
chef_apply
Provision with Chef 'cookbooks' and 'recipes' using a Chef Server. chef_solo
doesn't need a server and is easy to setup.
docker The docker provisioner can automatically install Docker, pull Docker
containers, and configure certain containers to run on boot.
puppet,
puppet_server
The Puppet provisioner, 'puppet' does not require a Puppet Master.
salt The salt Provisioner allows you to provision the guest using Salt states.
https://docs.vagrantup.com/v2/provisioning/index.html
18. January 20, 2016 Overview of Vagrant 18
Using Vagrant for Web DevelopmentUsing Vagrant for Web Development
●
Scenario:Scenario:
●
Zurb Foundation for front-end (v. 6.1.0, downloaded)Zurb Foundation for front-end (v. 6.1.0, downloaded)
●
Python Django for back-end (v. 1.9.1, not stock Ubuntu)Python Django for back-end (v. 1.9.1, not stock Ubuntu)
●
IDE on host: Sublime TextIDE on host: Sublime Text
●
Challenges:Challenges:
●
Zurb Foundation installed using npm and bootstrapped usingZurb Foundation installed using npm and bootstrapped using
CLI and Sass/CSS toolchainCLI and Sass/CSS toolchain
●
Django downloaded using pip and bootstrapped using CLIDjango downloaded using pip and bootstrapped using CLI
●
Django runs in its own Python3 virtualenvDjango runs in its own Python3 virtualenv
●
Don't forget the database!Don't forget the database!
19. January 20, 2016 Overview of Vagrant 19
BackgroundBackground●
Zurb FoundationZurb Foundation
●
'A front-end Framework is a collection of HTML, CSS, and JavaScript containing design patterns that'A front-end Framework is a collection of HTML, CSS, and JavaScript containing design patterns that
you can build upon. They keep you from wasting time rewriting boring, boilerplate code over and overyou can build upon. They keep you from wasting time rewriting boring, boilerplate code over and over
again.' –again.' – http://foundation.zurb.com/learn/about.htmlhttp://foundation.zurb.com/learn/about.html
●
DjangoDjango
●
'With Django, you can take Web applications from concept to launch in a matter of hours. Django takes'With Django, you can take Web applications from concept to launch in a matter of hours. Django takes
care of much of the hassle of Web development, so you can focus on writing your app without needingcare of much of the hassle of Web development, so you can focus on writing your app without needing
to reinvent the wheel. It’s free and open source.' –to reinvent the wheel. It’s free and open source.' – https://www.djangoproject.com/start/overview/https://www.djangoproject.com/start/overview/
●
BowerBower
●
'Bower can manage components that contain HTML, CSS, JavaScript, fonts or even image files. Bower'Bower can manage components that contain HTML, CSS, JavaScript, fonts or even image files. Bower
doesn’t concatenate or minify code or do anything else - it just installs the right versions of thedoesn’t concatenate or minify code or do anything else - it just installs the right versions of the
packages you need and their dependencies.' –packages you need and their dependencies.' – http://bower.io/http://bower.io/
●
npmnpm
●
'npm makes it easy for JavaScript developers to share and reuse code, and it makes it easy to update'npm makes it easy for JavaScript developers to share and reuse code, and it makes it easy to update
the code that you're sharing.' –the code that you're sharing.' – https://docs.npmjs.com/getting-started/what-is-npmhttps://docs.npmjs.com/getting-started/what-is-npm
●
pippip
●
'pip is a package management system used to install and manage software packages written in'pip is a package management system used to install and manage software packages written in
Python.' –Python.' – https://en.wikipedia.org/wiki/Pip_(package_managerhttps://en.wikipedia.org/wiki/Pip_(package_manager))
20. January 20, 2016 Overview of Vagrant 20
Provisioning ApproachProvisioning Approach
● Step 1:Step 1: vagrant upvagrant up
●
Import VMImport VM
●
Provision usingProvision using
AnsibleAnsible
– Install latest NodeJSInstall latest NodeJS
– Install 'step 2'Install 'step 2'
dependenciesdependencies
– Install PostgreSQLInstall PostgreSQL
– Create vagrant user inCreate vagrant user in
databasedatabase
● Step 2:Step 2: vagrantvagrant
sshssh
●
Run setup.sh scriptRun setup.sh script
– Excute 'npm install'Excute 'npm install'
and 'bower install'and 'bower install'
– 'foundation build' to'foundation build' to
build CSS from Sassbuild CSS from Sass
– Install PythonInstall Python
virtualenvvirtualenv
– Django 'migrate' DBDjango 'migrate' DB
and 'createsuperuser'and 'createsuperuser'
●
Run only one time!Run only one time!
21. January 20, 2016 Overview of Vagrant 21
Eliminating Step 2Eliminating Step 2
●
The 'setup.sh' script can be replaced with theThe 'setup.sh' script can be replaced with the
Ansible provisioner insteadAnsible provisioner instead
●
Advantages: can go into 'airplane mode' afterAdvantages: can go into 'airplane mode' after
provisioningprovisioning
●
Ansible package modules: pip, bower, npmAnsible package modules: pip, bower, npm
●
Bower and npm directories in a VM instanceBower and npm directories in a VM instance
directory (/home/vagrant) not project directorydirectory (/home/vagrant) not project directory
●
Modifications will be left as an exercise for theModifications will be left as an exercise for the
readerreader
22. January 20, 2016 Overview of Vagrant 22
Provisioning DemoProvisioning Demo
23. January 20, 2016 Overview of Vagrant 23
Vagrant ShareVagrant Share
●
Tunnel HTTP and SSH ports through a proxyTunnel HTTP and SSH ports through a proxy
●
Example: http://ghastly-wombat-4051.vagrantshare.comExample: http://ghastly-wombat-4051.vagrantshare.com
●
Requires account on atlas.hasicorp.comRequires account on atlas.hasicorp.com
● vagrant loginvagrant login
● vagrant sharevagrant share
●
URL can be on your domain (--domain)URL can be on your domain (--domain)
●
Share SSH sessionsShare SSH sessions
● vagrant share --sshvagrant share --ssh
● vagrant connect --sshvagrant connect --ssh
24. January 20, 2016 Overview of Vagrant 24
Creating BoxenCreating Boxen
25. January 20, 2016 Overview of Vagrant 25
Box Creation LifecycleBox Creation Lifecycle
$ packer
build
OS ISO image
1st box
$ vagrant
package
2nd box
etc...
● packerpacker
●
install from installation ISO's to temp VMinstall from installation ISO's to temp VM
● vagrant packagevagrant package
●
import from existing VM with Vagrant customizaionsimport from existing VM with Vagrant customizaions
VM
instance
$ vagrant box
add
$ vagrant up
26. January 20, 2016 Overview of Vagrant 26
vagrant packagevagrant package
● vagrant packagevagrant package takes an existing VM andtakes an existing VM and
outputs a re-usable .box fileoutputs a re-usable .box file
●
The .box file can be added to the repositoryThe .box file can be added to the repository
usingusing vagrant box addvagrant box add
●
It can be copied up to a web server for URLIt can be copied up to a web server for URL
distributiondistribution
●
Using existing Vagrant instance is easiest as it hasUsing existing Vagrant instance is easiest as it has
'vagrant' user, networking, VB guest additions, etc.'vagrant' user, networking, VB guest additions, etc.
$ vagrant
package
VM
instance
my_precious.box
$ vagrant box
add
27. January 20, 2016 Overview of Vagrant 27
PackerPacker
● packerpacker is a tool to create Vagrant boxes fromis a tool to create Vagrant boxes from
bare metal virtual machinesbare metal virtual machines
●
https://www.packer.io/https://www.packer.io/
●
Packer templates are JSON files:Packer templates are JSON files:
●
Chef / bento:Chef / bento: https://github.com/chef/bentohttps://github.com/chef/bento
– used internally by Chef to build base boxesused internally by Chef to build base boxes
●
Boxcutter:Boxcutter: https://github.com/boxcutterhttps://github.com/boxcutter
– community-driven templates that are CM tool-agnosticcommunity-driven templates that are CM tool-agnostic
$ packer
build
OS ISO image my_precious.box
28. January 20, 2016 Overview of Vagrant 28
Hashicorp AtlasHashicorp Atlas
Boxes can be built in the cloud using templates pushed up by packer. For example,
need to build a box for VMWare desktop but you don't have VMWare? Not a
problem. See http://atlas.hashicorp.com for more information.
29. January 20, 2016 Overview of Vagrant 29
Box VersioningBox Versioning
●
Boxes may be versioned usingBoxes may be versioned using semanticsemantic
versioningversioning (e.g. 1.0.9)(e.g. 1.0.9)
●
Versioning is default for Atlas hosted boxesVersioning is default for Atlas hosted boxes
●
NoteNote vendor/boxnamevendor/boxname conventionconvention
●
For self-hosted boxes, couple of choices...For self-hosted boxes, couple of choices...
●
No versioning, use naming convention instead inNo versioning, use naming convention instead in
vagrant box addvagrant box add (e.g. 'django-v1.0.0')(e.g. 'django-v1.0.0')
●
Yes versioning, use 'metadata.json' versioningYes versioning, use 'metadata.json' versioning
control in Vagrantcontrol in Vagrant
30. January 20, 2016 Overview of Vagrant 30
Self-hosted VersioningSelf-hosted Versioning
●
Generate and hostGenerate and host
metadata.json yourselfmetadata.json yourself
●
Nice tool to gen jsonNice tool to gen json
●
pip install vagrant-metadatapip install vagrant-metadata
●
Upload to web orUpload to web or
network sharenetwork share
●
Using box:Using box:
● vagrant initvagrant init
cperez/djsitecperez/djsite
http://localhost/boxes/djsite/metadata.jsonhttp://localhost/boxes/djsite/metadata.json
● Upgrading:Upgrading: vagrantvagrant
box updatebox update
{
"name": "cperez/djsite",
"description": "Django box",
"baseurl":
"http://localhost/boxes/djsite",
"versions": [
{
"version": "1.0.0",
"providers": [
{
"name": "virtualbox",
"checksum_type":
"sha1",
"checksum":
"5bb7c7580712a547a7f30da920c2fb1e2430f904"
,
"url":
"http://localhost/boxes/djsite/1.0.0/virtu
albox/djsite-1.0.0.box"
}
]
}
]
}
31. January 20, 2016 Overview of Vagrant 31
Provisioning vs. PackagingProvisioning vs. Packaging
●
Best to take a base box, provision it, and thenBest to take a base box, provision it, and then
'freeze' it using'freeze' it using vagrant packagevagrant package
● speeds upspeeds up vagrant destroyvagrant destroy // vagrant upvagrant up
cyclecycle
●
can include a Vagrantfile with the box with preferredcan include a Vagrantfile with the box with preferred
settings (such as networking and port forwards)settings (such as networking and port forwards)
●
Nice recipes:Nice recipes:
– https://github.com/pro-vagranthttps://github.com/pro-vagrant
●
Best to keep box packaging scripts in separateBest to keep box packaging scripts in separate
directorydirectory
32. January 20, 2016 Overview of Vagrant 32
Multiple MachinesMultiple Machines
●
Mulit-machine can beMulit-machine can be
specified inspecified in
VagrantfileVagrantfile
●
Name each machineName each machine
● vagrant ssh webvagrant ssh web
●
Networking optionsNetworking options
allow for machine toallow for machine to
machinemachine
communicationscommunications
Vagrant.configure("2") do |config|
config.vm.provision "shell", inline:
"echo Hello"
config.vm.define "web" do |web|
web.vm.box = "apache"
end
config.vm.define "db" do |db|
db.vm.box = "mysql"
end
end
33. January 20, 2016 Overview of Vagrant 33
Vagrant SecurityVagrant Security
●
By default, Vagrant boxes areBy default, Vagrant boxes are insecureinsecure
●
For local development, not productionFor local development, not production
●
Keep your box behind a firewall, not on Internet!Keep your box behind a firewall, not on Internet!
●
Public boxes contain the 'insecure private key'Public boxes contain the 'insecure private key'
●
https://github.com/mitchellh/vagrant/tree/master/keyshttps://github.com/mitchellh/vagrant/tree/master/keys
●
Default password is 'vagrant'Default password is 'vagrant'
● OnOn vagrant upvagrant up, the insecure key is replaced with a, the insecure key is replaced with a
local 'insecure key'local 'insecure key'
● vagrant packagevagrant package may create box with newmay create box with new
vagrant_private_keyvagrant_private_key
34. January 20, 2016 Overview of Vagrant 34
Other TipsOther Tips
●
Unix vs. DOS line feeds, confuses shell and file provisioners. Standardize onUnix vs. DOS line feeds, confuses shell and file provisioners. Standardize on
Unix line endings (LF) in your IDE's.Unix line endings (LF) in your IDE's.
●
C++ developers: cannot execute built binaries from /vagrant mount? Copy toC++ developers: cannot execute built binaries from /vagrant mount? Copy to
/home/vagrant./home/vagrant.
●
Running FreeBSD and the nfs folder sync doesn't work because your homeRunning FreeBSD and the nfs folder sync doesn't work because your home
directory is encrypted? Try 'rsync' option for folder syncing.directory is encrypted? Try 'rsync' option for folder syncing.
●
Box versioning: best to specify a version in Vagrantfile rather thanBox versioning: best to specify a version in Vagrantfile rather than
downloading latest base box.downloading latest base box.
●
Ubuntu guest: remove 'mesg n' in /root/.profile to eliminate annoying 'default:Ubuntu guest: remove 'mesg n' in /root/.profile to eliminate annoying 'default:
stdin: is not a tty' message when using shell provisioner.stdin: is not a tty' message when using shell provisioner.
35. January 20, 2016 Overview of Vagrant 35
Thank You!Thank You!
●
Sample Vagrant project with Django andSample Vagrant project with Django and
Foundation:Foundation:
https://github.com/coloradocarlos/djfoundation1https://github.com/coloradocarlos/djfoundation1
●
Contact: perez@doorstep.comContact: perez@doorstep.com
Editor's Notes
Survey:
Do you virtualize your development environment? Production environment?
VirtualBox? VMWare? Others?
Traditional development environments have everyone work on native host platforms, IDE&apos;s and tool chains.
Byte-code languages (.NET, Java) and portable interpreters (PHP, Python) have been able to firewall developers from host-specific differences.
Model works reasonably well in shops that control dev. environment (e.g. the IT locked down laptop), but in BYOM environments, consistency and stability is difficult.
When it is time to move your app to the cloud, it is not likely that your laptop environment will be easily replicated.
Developers work with a number of programming languages and environments.
Some languages, such as C, C++, Assembly are tightly coupled to the machine architecture.
Some platforms, such as ARM, require cross-compilers and vendor tool chains that are tricky and difficult to get setup.
Provisioning a dev. environment is time consuming-- automate and streamline the process with Vagrant.
A virtualized dev. environment, if done correctly, mimics your production environment.
Vagrant also is a path for shops with strong DevOps workflow-- DevOps can (and should) be involved with building Vagrant instances.
CONS of using Vagrant:
Need powerful machine and lots of disc space
Virtualization may not work well for all cases: driver or RTOS embedded development, or non-web GUI development (e.g. Qt)
Vagrant is a &apos;shell&apos; for starting and stopping VM&apos;s.
Host: serves as your front end to your IDE, browser, and SCM.
Guest: typically runs headless using port forwards and synced folders. Access using SSH.
When developing in dynamically typed languages such as PHP, may not even need to ssh in to start services
mkdir foo
cd foo
vagrant init ubuntu/trusty32
vagrant up
ls -lsat
vagrant ssh-config
vagrant ssh
vagrant halt
vagrant destroy
rm -rf .vagrant
cd ..
rmdir foo
Vagrant is open source!
Written in Ruby.
&apos;vagrant ssh-config&apos; displays current ssh configuration
&apos;vagrant rdp&apos; allows one to connect to a machine using the RDP protocol.
&apos;vagrant powershell&apos; for Windows servers.
&apos;vagrant port&apos; shows the port forwards in use.
&apos;vagrant init&apos; will default to Atlas if no URL is secified for box URL
&apos;vagrant snapshot&apos; allows you to create and restore snapshots of your VM
&apos;vagrant init&apos; will create a Vagrantfile for you with the box set to &apos;ubuntu/trusty32&apos;. By default, it will use the Atlas URL to find boxes.
A .vagrant directory is created in the project folder.
Show example of shell provisioner.
Walk through Foundation and Django.
To use sharing, need to sign up for an account on Hashicorp.
vagrant ssh; start web server
vagrant share --domain vagrantshare.doorstep.com --name demo
Go to: http://demo.vagrantshare.doorstep.com
SSH sessions can also be tunnelled. Private key is encrypted for additional security on the Internet.
vagrant package:
On guest:
vi /etc/hostname (change hostname to djsite-v1-0)
history -c; history -w
exit
On host:
vagrant package --output djsite-v1.0.box --vagrantfile Vagrantfile.pkg
vagrant box add djsite-v1.0 djsite-v1.0.box
cd ..; mkdir djsite2; cd djsite2
vagrant init -m djsite-v1.0
vagrant up
An advantage of packaging your own box is that it is already provisioned the way you like.
vagrant package:
On guest:
sudo vi /etc/hostname (change to djsite-v1-0)
history -c; history -w
exit
On host:
vagrant package --output djsite-v1.0.box --vagrantfile Vagrantfile.pkg
vagrant box add djsite-v1.0 djsite-v1.0.box
cd ..; mkdir djsite2; cd djsite2
vagrant init -m djsite-v1.0
vagrant up
vagrant box list
Show difference between boxes that are versioned and those that are not.
Note the &apos; config.vm.box_version = &quot;20151218.0.1&quot;&apos; in Vagrantfile
Once a .box file is created from packaging, then it can be distributed
Tool: https://github.com/lvillani/vagrant-metadata/
cd ~/Doorstep/vagrant/boxes/djsite
vagrant-metadata -n &quot;cperez/djsite&quot; -d &quot;Django box&quot; --baseurl=&quot;http://localhost/boxes/djsite&quot;
Directory is symlinked to http://localhost for ease of syncing
Then create a new directory somewhere:
vagrant init cperez/djsite http://localhost/boxes/djsite/metadata.json
Good to go with &apos;vagrant up&apos;