Create a Windows development enviroment with Packer, Vagrant & Chocolatey
Switch branches/tags
Nothing to show
Clone or download
Latest commit f7fe98c Jun 15, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
boxstarter Update setup.ps1 Jun 15, 2018
env Add env helpers Jan 19, 2018
helpers Remove vagrant version specific install May 17, 2017
scripts Add vscode extensions Jul 31, 2017
.gitignore Added gitignore and removed file provision Jul 28, 2016
README.md Update README.md Aug 24, 2017
Vagrantfile Add vs code to provision Jul 31, 2017

README.md

Pioneer Code Windows Development Environment With Packer, Vagrant, and Chocolatey

Overview

A general development environment for Windows. It is also worth noting that I use this on a daily basis, including on the job.

Who is this for?

  • Tired of messing up your PC with outdated assets that degrade over time?
  • Tired of the amount of time it takes for you to set up a new dev environment?
  • Prefer some modern-day comforts such as configurable, reproducible and portable environments.

If you answered yes to any of these questions, then this workflow might be for you.

Setup

On your local machine, run the following from an elevated command prompt. Do not run these commands from a PowerShell prompt.

Install Chocolatey

@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin

Install Vagrant

cinst vagrant -y

Install Git

cinst git.install -y

Virtualization

VirtualBox

Free - You need to install this even if you plan on using VMware Workstation

cinst virtualbox -y

VMWare

Not Free - VirtualBox works great. If you prefer VMware Workstation, you also need to secure the Vagrant + VMware plugin.

cinst vmwareworkstation -y

Clone repo.

git clone https://github.com/PioneerCode/pioneer-windows-development-environment.git

Vagrant Box

Vagrant requires Boxes. If you don't already have a Windows Box, there are a few different ways you can get one.

  • Make your own from scratch.
    • There are plenty of tutorials available online.
  • Make your own using Packer.
    • Packer is widely used and made by the same people who make Vagrant.
    • Joe Fitzgerald's repo is highly recommended and takes a lot of guess-work out of the process.
      • It is highly recommended that you build your Windows boxes with winrm instead of ssh. Long story short, this solves a lot of know issues with Vagrant and Windows communicating with each other.
      • That being said, if you are using packer to build your box and more specifically Joe Fitzgerald's repo, I recommend you use the branch that has the necessary adjustments to implement winrm.
  • Use one that is available from the community.

Once you have secured your box, navigate to it.

cd {path-to-box}

Add your Box to Vagrant

vagrant box add {name-of-box} {path-to-box.box} 

Verify your Box is in Vagrant

vagrant box list

Vagrantfile

In the pioneer-windows-development-environment repo, there is a file called Vagrantfile. Open it up and ensure the following line matches the name you provided above.

config.vm.box = {name-of-box}

Provision

Depending on what you want to be installed coming out of the gates, you might want to take a quick look at the provision scripts located in the scripts folder. Most of what is needed for our entire stack is already configured inside these files. That being said, you might have some personal preferences. Open each up to take a quick look and make any adjustments you see fit.

Typically, you would want to at least open up install-programs.ps1 and select the appropriate version of Visual Studio to be installed. As a default, Visual Studio 2017 Enterprise edition is provisioned.

When to run scripts

Some people will want to run scripts as provisions of vagrant up, others might want to move the script files to their new VM and run them at will. By default, the Vagrantfile is set to run a few scripts that I know I will always need to be run. If you prefer, you can comment those provision out and uncomment the "file" provision. The "file" provision will instead move the scripts to the c:\users\vagrant\documents\script. This will allow you to run them whenever you see fit.

Run

Depending on your environment, run one of the following. Default == VirtualBox.

vagrant up
vagrant up --provider vmware_workstation
vagrant up --provider vmware_fusion
vagrant up --provider hyperv

This will configure and create, if not already done, a guest machine for you. Depending on what you are installing, this will take anywhere from a minute (empty guest) to about 30 mins (default provisions) to complete.

Know Issues

  • SQL Server Managemnt Studio might not install.
    • Sometimes need to re-run cinst -y sql-server-management-studio after the initial provision.