Skip to content

Building a development environment with Vagrant, Packer, Windows 10 and Server 2016

License

Notifications You must be signed in to change notification settings

jacqinthebox/packer-templates

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Windows templates for Packer

Introduction

This repository contains Windows templates that can be used to create boxes for Vagrant using Packer. It is inspired by https://github.com/mwrock/packer-templates and by https://github.com/MattHodge/PackerTemplates. I was a bit stuck until I read https://hodgkins.io/best-practices-with-packer-and-windows. My previous approach of stuffing all box creating effort in 1 file was very cumbersome. Turns out you can use a modular approach with Packer by creating multiple artifacts and chain them together.

How to

Prerequisites

The Windows boxes are created with Packer version 1.5.1 and are using WinRM. Vagrant, Packer and Virtualbox.

Linux: Install them with your package provider or manually, for example like so:

wget https://releases.hashicorp.com/vagrant/2.2.6/vagrant_2.2.6_linux_amd64.zip
unzip vagrant_2.2.6_linux_amd64.zip
sudo mv vagrant /usr/local/bin

wget https://releases.hashicorp.com/packer/1.5.1/packer_1.5.1_linux_amd64.zip
unzip packer_1.5.1_linux_amd64.zip
sudo mv packer /usr/local/bin

Windows VirtualBox:

You can install the prerequisites with packagemanagement:

Install-Package -ProviderName Chocolatey -ForceBootstrap -Force vagrant,virtualbox,packer

Clone and run

Clone the repository:

git clone https://github.com/jacqinthebox/packer-templates.git; cd packer-templates

Create a box

Create a Windows 10 box:

packer build --force virtualbox_windows_10_1_base.json
packer build --force virtualbox_windows_10_2_updates.json
packer build --force virtualbox_windows_10_3_package.json

Create a Windows Server 2019 box:

packer build --force virtualbox_windows_server_2019_1_base.json
packer build --force virtualbox_windows_server_2019_2_updates.json
packer build --force virtualbox_windows_server_2019_3_package.json

Add the box to Vagrant

vagrant box add --name windows_10 windows10_vbox.box

Or just use the boxes from the Vagrant cloud

Create a Vagrantfile

Vagrant.configure("2") do |config|
  config.vm.define "lab01" do |lab01_config|
    lab01_config.vm.box = "jacqinthebox/windows10"
    lab01_config.vm.hostname ="lab01"
    
    lab01_config.vm.provider "virtualbox" do |v|
      v.linked_clone = true
    end
  end
end

And do

vagrant up

This may take a while because the boxes are around 6 Gigabytes.

https://app.vagrantup.com/boxes/search?order=desc&page=1&provider=&q=jacqinthebox