• Stars
    star
    161
  • Rank 233,470 (Top 5 %)
  • Language
    PowerShell
  • Created about 8 years ago
  • Updated almost 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Packer Templates for building Windows Operating Systems

Windows Packer Templates

Introduction

This repository contains build scripts to golden images using Packer.

Interested in some best practices when using Packer with Windows? Check out my blog post on the topic.

Supported Builders

The supported builds are:

  • VirtualBox
  • Hyper-V

Supported Operating Systems

The build.supported_os.yaml file contains the list of Operating Systems that are supported and their settings.

The supported Operating Systems to build are:

  • Windows2012R2Core
  • Windows2012R2
  • Windows2016StdCore
  • Windows2016Std

Pre-build Images

If you just want to download the pre-build Vagrant images, download them from Vagrant Cloud.

Prepare your system to run Packer

Before you can run the build scripts, you need to prepare your system.

Ubuntu

✅ Tested on Ubuntu 16.04

Mono is required to run the build script.

# Install Mono
sudo apt-get install mono-complete -y

# Give the script execute permission
chmod +x build.sh

Additionally you will need to install:

  • Packer
  • VirtualBox

Windows

✅ Tested on Windows 10 Pro

# Set PowerShell Execution Policy
Set-ExecutionPolicy RemoteSigned -Force

# Install Chocolatey
iwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex

# Install Packer
choco install packer -y

# Install Hyper-V
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All

# Create an external Hyper-V Switch
# Commands may vary depending on your system.
Get-NetAdapter

# Find the name of the network adapter (make sure its status is also not disconnected)

# Create a new VM Switch using the name of the network adapter
New-VMSwitch -Name "External VM Switch" -AllowManagementOS $true -NetAdapterName "<Your Adapter Name Here>"

Running the Build Script

Depending on your platform, you either need to run:

  • build.ps1 on Windows
  • build.sh on Linux / MacOS.

Building Vagrant Cloud Images

If you are building images for Vagrant Cloud, you need to set the following environment variables:

# Windows

$env:ATLAS_TOKEN = "ABC123XYZ"

$env:ATLAS_USERNAME = "MattHodge" # Username to upload the boxes under

$env:ATLAS_VERSION = "1.0.1" # Version of the box being uploaded
# MacOS / Linux

export ATLAS_TOKEN="ABC123XYZ"

export ATLAS_USERNAME="MattHodge" # Username to upload the boxes under

export ATLAS_VERSION="1.0.1" # Version of the box being uploaded

Building Hyper-V Images

The following commands will build you Hyper-V Images

# Builds Windows 2016 Standard Core and runs the Vagrant post processor (local).
.\build.ps1 -Target "hyperv-local" -os="Windows2016StdCore"

# Builds Windows 2012 R2 Core and runs the Atlas post processor.
.\build.ps1 -Target "hyperv-vagrant-cloud" --os="Win2012R2Core"

Building VirtualBox Images

The following commands will build you VirtualBox Images

# Builds Windows 2016 Standard Core and runs the Vagrant post processor (local).
./build.sh --target "virtualbox-local" -os="Windows2016StdCore"

# Builds Windows 2012 R2 Core and runs the Atlas post processor.
./build.sh --target "virtualbox-vagrant-cloud" -os="Win2012R2Core"

Using the Vagrant Images

If you aren't pushing your boxes to Atlas, you can import the *.box files for use in Vagrant:

vagrant box add .\win2016stdcore-wmf5-nocm-hyperv.box --name Windows2016StdCore

You can also find all the boxes ready to be used with vagrant up over at my VagrantBoxes Repository.

More Repositories

1

Graphite-PowerShell-Functions

A group of PowerShell functions that allow you to send Windows Performance counters to a Graphite Server, all configurable from a simple XML file.
PowerShell
218
star
2

PoshHubot

PowerShell Module for Hubot
PowerShell
42
star
3

MattHodgePowerShell

Various PowerShell functions and scripts
PowerShell
28
star
4

terraform-provider-octopusdeploy

An Octopus Deploy Terraform Provider
Go
24
star
5

Hubot-DSC-Resource

PowerShell DSC Resource to install Hubot on Windows
PowerShell
21
star
6

ansible-testkitchen-windows

Running Ansible playbooks against Windows and testing with Pester
PowerShell
19
star
7

WindowsErrbot

Quick start for Errbot on Windows with PowerShell Integration
Python
17
star
8

PoshSensu

PoshSensu is a PowerShell module to handle running PowerShell scripts as Sensu checks. The results are submitted to a Sensu client via the client socket input feature that the Sensu client provides.
PowerShell
16
star
9

PagerDuty-PowerShell-CmdLets

PowerShell CmdLets for using the PagerDuty API.
PowerShell
16
star
10

go-teedy

A Go client library and CLI for accessing the API of Teedy.
Go
10
star
11

go-octopusdeploy

A Go wrapper for the Octopus Deploy REST API
Go
9
star
12

VagrantBoxes

Random VagrantBoxes
PowerShell
8
star
13

datadog-terraform-example

Example of DataDog Terraform Repo
HCL
8
star
14

HubotWindowsContainer

PowerShell
5
star
15

HubotWindows

A Hubot setup especially for Windows
CoffeeScript
5
star
16

splunk

Splunk Demos and Datafiles
Python
4
star
17

books

4
star
18

PSErrbot

PowerShell Errbot
Python
3
star
19

ansible-docker

Docker Container for running Ansible with support for WinRM
Dockerfile
3
star
20

awesome-datadog

A curated list of awesome DataDog libraries, open source repos, guides, blogs, and other resources.
2
star
21

AnsibleDemo

2
star
22

PSHubotDocker

JavaScript
2
star
23

go-fiber-templ-goth-aad-example

Go
2
star
24

docker_elk_with_redis

1
star
25

OctopusDeployAutomation

Cake Scripts to Automate Creation of Octopus Deploy Projects via YAML
C#
1
star
26

presentation_chatops_powershell

PowerShell
1
star
27

matthodge.github.io

Matthew Hodgkins Blog
CSS
1
star
28

ansible-role-mdt

Ruby
1
star
29

alexa

Alexa Projects
JavaScript
1
star
30

test-monorepo-auto

A monorepo to test intuit / auto
Shell
1
star