Vagrant
lightweight,
reproducible,
& portable
development environments
Memphis Python User Group
02/17/2014
Who is this guy!?
Joe Ferguson
Professionally
Semi Professional
What is vagrant?
Tool for building complete dev environments
Easy to use workflow
Focus on automation
Lowers Dev Environment setup time
- Increase Dev / Live Environment Parity
Terminology
Vagrant configures a Provider
Provisioners Configure the VM
Vagrant use case
Spin up a server for:
- Test versions of your web app
- Test group policy permissions
- Test system updates before live
Spin up a desktop for:
- Test versions of your system app
- Isolate your development tools
-
Test system updates before live
Provisioning
How do you currently configure your environment?
Stop manually installing apps and configuring settings!
Which provisioner?
Chef - Cookbook based
Puppet - Manifest based
Shell (Batch Files) - Who doesn't love the shell?!
Vagrant philosophies
Why manually do something when your can let your provisioner do it for you?
Vagrant boxen are insecure, defaults to vagrant/vagrant
Vagrant uses Windows Remote Management tool (WinRM) to interact with your box
User Access Control (UAC) is a bad idea*
You will also need vagrant-windows plugin
User Access control*
In general, UAC is a bad idea because it likes to interfere with vagrants handling of your machine.**
If you're wanting to test UAC, be weary of any odd things may be a result of vagrant and UAC being enabled**
** I am not a windows guy, Brian made me do this. Feel free to correct me!
Go download a vagrant box!
OH WAIT!
You all have to deal with licensing...
Let's make a vagrant box!
First we have to create a Virtual Machine...
- install a base windows system
- install guest additions
- create vagrant user as admin
- turn off UAC
- disable complex passwords*
- disable shutdown tracker
- disable server manager starting
- Enable and configure WinRM
- WinRM 1.1 needs more tweaks
Save the VM as a box
c:\>vagrant package --base VM-Name --output MyFirstBox.box
This will:
- halt the VM
- export the VM
- compress the VM
What you will have is "MyFirstBox.box"
Add the new Vagrant box
Now that we have MyFirstBox.box, we need to add it to vagrant's available boxes.
c:\>vagrant box add MyFirstBox MyFirstBox.box
This will import the box into vagrant and when this process completes:
c:\>vagrant box list
You should see "MyFirstBox" in the list of available boxes
Creating the vagrant file
Create a folder to hold our Vagrant Project
C:\>mkdir VagrantRocks
C:\> cd VagrantRocks
C:\>vagrant init
This will put a Vagrantfile in VagrantRocks/
Edit Vagrant file based on the sample found here:
Tweaking the Vagrant File
You will likely need to change the forwarded port 3389 if you have Remote Desktop enabled.
Feel free to use my sample as a guide:
The Vagrant File
Vagrant.configure("2") do |config|
# Configure base box parameters
config.vm.box = "MyFirstBox"
# config.vm.box_url = "./vagrant-windows7x64box"
config.vm.guest = :windows
config.vm.provider :virtualbox do |vb|
vb.gui = true
end
config.windows.set_work_network = "1"
config.winrm.host = "localhost"
# Port forward WinRM and RDP
config.vm.network :forwarded_port, guest: 3389, host: 3389
config.vm.network :forwarded_port, guest: 5985, host: 5985, id: "winrm", auto_correct: true
end