The Wayback Machine - https://web.archive.org/web/20200526052602/https://github.com/StefanScherer/packer-windows
Skip to content
Windows Templates for Packer: Win10, Server 2016, 1709, 1803, 1809, 2019, 1903, 1909, 2004, Insider with Docker
PowerShell Ruby Batchfile Python Shell HCL Dockerfile
Branch: my
Clone or download
This branch is 898 commits ahead, 64 commits behind joefitzgerald:master.

Latest commit

Latest commit 1d9e117 May 13, 2020

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
ansible Try to use Ansible to install Windows updates Oct 22, 2019
answer_files Add Windows Server, version 2004 May 13, 2020
bin Use upstream chocolatey packer Dec 23, 2018
floppy Remove blank in filename Dec 4, 2015
iso Adding README in ISO directory Jul 31, 2013
nested Install vagrant plugins Jan 21, 2018
scripts Fix debugging output in Check-WindowsUpdates May 7, 2020
test copies from my_vagrant_vcloud branch Dec 26, 2014
.gitattributes Improve Windows 10 1511 build Nov 27, 2015
.gitignore Chocolatey Fest 2018: Build server 2019 insider for Azure upload (#128) Sep 18, 2018
AZURE.md Add notice how to copy vhd with azure cli Jan 28, 2017
CHANGELOG.md Documented the new parallels support Dec 20, 2019
Dockerfile Skip windows_7.json in test Dec 29, 2019
LICENSE fixed licence to include Stefan Feb 7, 2020
README-ami.md add windows 2016 core image and remove vm guest tool installation Sep 18, 2018
README-dockerfile.md Fix typo Sep 18, 2018
README-rsync.md added README-rsync.md Aug 5, 2014
README-shutdown_command.md Shutdown windows_2016 with sysprep Sep 3, 2017
README.md Add Windows Server, version 2004 May 13, 2020
appveyor.yml Use upstream chocolatey packer Dec 23, 2018
build_windows_10.ps1 Update build scripts Jan 13, 2017
build_windows_10.sh Add Windows Server, version 2004 May 13, 2020
build_windows_10_docker.sh Update Docker 17.03.0-ce Mar 2, 2017
build_windows_10_insider.sh Update 19041 iso Apr 7, 2020
build_windows_2016_core.sh save build scripts Jul 25, 2017
build_windows_2016_dc.sh save build scripts Jul 25, 2017
build_windows_2016_docker.ps1 Update build scripts Jan 13, 2017
build_windows_2016_docker.sh Switch to growing disk Dec 9, 2017
build_windows_2016_docker_hyperv.ps1 Add hyperv build script Nov 6, 2016
build_windows_2019.sh Updating evaluation media Apr 6, 2019
build_windows_2019_docker.ps1 Updated ISO name and SHA for latest eval Apr 3, 2019
build_windows_2019_docker.sh
build_windows_2019_docker_azure.ps1 Rename azure template Sep 18, 2018
build_windows_server_1709_docker.sh Switch to growable disk Dec 10, 2017
build_windows_server_1803_docker.sh Add Windows Server, version 1803 May 8, 2018
build_windows_server_1809_docker.sh Add Windows Server 1809 Nov 21, 2018
build_windows_server_1903_docker.sh Add Windows Server, Version 1909 Dec 14, 2019
build_windows_server_1909_docker.sh Add Windows Server, Version 1909 Dec 14, 2019
build_windows_server_insider_docker.sh Update Windows Insider 19035 Dec 12, 2019
fix.sh Abort on error Dec 9, 2017
make_unattend_iso.ps1 Remove trailing spaces May 29, 2019
test.ps1 Skip windows_7.json in test Dec 29, 2019
upload-vhd.ps1 Update Docker image tags Oct 3, 2018
vagrantfile-windows_10.template Revert "Use vbox 6.1 parameter --clipboard-mode" Feb 26, 2020
vagrantfile-windows_2008_r2.template Revert "Use vbox 6.1 parameter --clipboard-mode" Feb 26, 2020
vagrantfile-windows_2012.template Revert "Use vbox 6.1 parameter --clipboard-mode" Feb 26, 2020
vagrantfile-windows_2012_r2.template Revert "Use vbox 6.1 parameter --clipboard-mode" Feb 26, 2020
vagrantfile-windows_2016.template Revert "Use vbox 6.1 parameter --clipboard-mode" Feb 26, 2020
vagrantfile-windows_2016_core.template Revert "Use vbox 6.1 parameter --clipboard-mode" Feb 26, 2020
vagrantfile-windows_2019_core.template Revert "Use vbox 6.1 parameter --clipboard-mode" Feb 26, 2020
vagrantfile-windows_7.template Revert "Use vbox 6.1 parameter --clipboard-mode" Feb 26, 2020
vagrantfile-windows_81.template Revert "Use vbox 6.1 parameter --clipboard-mode" Feb 26, 2020
validate.sh Validate VMware packer templates Jan 12, 2019
windows_10.json Export vm_name as user variable for Windows 10 Apr 27, 2020
windows_10_insider.json Update Windows Insider 19035 Dec 12, 2019
windows_2008_r2.json Rename ssh_wait_timeout to ssh_timeout Feb 26, 2020
windows_2008_r2_core.json Rename ssh_wait_timeout to ssh_timeout Feb 26, 2020
windows_2012.json Rename ssh_wait_timeout to ssh_timeout Feb 26, 2020
windows_2012_r2.json Fix hyperv keywords for packer 1.4.0 Apr 19, 2019
windows_2012_r2_core.json Fix hyperv keywords for packer 1.4.0 Apr 19, 2019
windows_2012_r2_hyperv.json Rename ssh_wait_timeout to ssh_timeout Feb 26, 2020
windows_2016.json Set hyperv vm version 8.0 Sep 25, 2019
windows_2016_ami.json Validate VMware packer templates Jan 12, 2019
windows_2016_core.json Set hyperv vm version 8.0 Sep 25, 2019
windows_2016_core_ami.json Validate VMware packer templates Jan 12, 2019
windows_2016_dc.json Fix hyperv keywords for packer 1.4.0 Apr 19, 2019
windows_2016_docker.json Update Docker 19.03.5 Nov 15, 2019
windows_2016_docker_azure.json Remove nanoserver sac2016 Apr 19, 2019
windows_2016_hyperv.json Set hyperv vm version 8.0 Sep 25, 2019
windows_2019.json Update Windows 2019 Eval ISO Jan 15, 2020
windows_2019_core.json Update Windows 2019 Eval ISO Jan 15, 2020
windows_2019_core_ami.json Update Windows 2019 Eval ISO Jan 15, 2020
windows_2019_docker.json Update Windows 2019 Eval ISO Jan 15, 2020
windows_2019_docker_azure.json Update Windows 2019 Eval ISO Jan 15, 2020
windows_2019_hyperv.json Add HyperV Server 2019 Sep 4, 2019
windows_7.json Export vm_name as user variable for Windows 7 Apr 27, 2020
windows_81.json Rename ssh_wait_timeout to ssh_timeout Feb 26, 2020
windows_server_1709.json Fix hyperv keywords for packer 1.4.0 Apr 19, 2019
windows_server_1709_docker.json Update Docker 19.03.5 Nov 15, 2019
windows_server_1803.json Fix hyperv keywords for packer 1.4.0 Apr 19, 2019
windows_server_1803_docker.json Update Docker 19.03.5 Nov 15, 2019
windows_server_1809.json Add Windows Server, Version 1909 Dec 14, 2019
windows_server_1809_docker.json Add Windows Server, Version 1909 Dec 14, 2019
windows_server_1903.json Add Windows Server, Version 1909 Dec 14, 2019
windows_server_1903_docker.json Add Windows Server, Version 1909 Dec 14, 2019
windows_server_1909.json Add Windows Server, Version 1909 Dec 14, 2019
windows_server_1909_docker.json Add Windows Server, Version 1909 Dec 14, 2019
windows_server_2004.json Add Windows Server, version 2004 May 13, 2020
windows_server_insider.json Add Windows Server, Version 1909 Dec 14, 2019
windows_server_insider_docker.json Add Windows Server, Version 1909 Dec 14, 2019

README.md

Windows Templates for Packer

Build status

Introduction

This repository contains Windows templates that can be used to create boxes for Vagrant using Packer (Website) (Github).

This repo is a modified fork of the popular joefitzgerald/packer-windows repo.

Some of my enhancements are:

  • Support of fullscreen Retina display on a MacBook Pro.
  • WinRM, no more OpenSSH

Packer Version

Packer 1.3.3 is recommended.

Windows Versions

The following Windows versions are known to work (built with VMware Fusion Pro 11.0.2):

You may find other packer template files, but older versions of Windows doesn't work so nice with a Retina display.

Windows Editions

All Windows Server versions are defaulted to the Server Standard edition. You can modify this by editing the Autounattend.xml file, changing the ImageInstall>OSImage>InstallFrom>MetaData>Value element (e.g. to Windows Server 2012 R2 SERVERDATACENTER).

To retrieve the correct ImageName from an ISO file use the following two commands.

PS C:\> Mount-DiskImage -ImagePath C:\iso\Windows_InsiderPreview_Server_2_16237.iso
PS C:\> Get-WindowsImage -ImagePath e:\sources\install.wim

ImageIndex       : 1
ImageName        : Windows Server 2016 SERVERSTANDARDACORE
ImageDescription : Windows Server 2016 SERVERSTANDARDACORE
ImageSize        : 7,341,507,794 bytes

ImageIndex       : 2
ImageName        : Windows Server 2016 SERVERDATACENTERACORE
ImageDescription : Windows Server 2016 SERVERDATACENTERACORE
ImageSize        : 7,373,846,520 bytes

Product Keys

The Autounattend.xml files are configured to work correctly with trial ISOs (which will be downloaded and cached for you the first time you perform a packer build). If you would like to use retail or volume license ISOs, you need to update the UserData>ProductKey element as follows:

  • Uncomment the <Key>...</Key> element
  • Insert your product key into the Key element

If you are going to configure your VM as a KMS client, you can use the product keys at http://technet.microsoft.com/en-us/library/jj612867.aspx. These are the default values used in the Key element.

Using existing ISOs

If you have already downloaded the ISOs or would like to override them, set these additional variables:

  • iso_url - path to existing ISO
  • iso_checksum - md5sum of existing ISO (if different)
packer build -var 'iso_url=./server2016.iso' .\windows_2016.json

Windows Updates

The scripts in this repo will install all Windows updates – by default – during Windows Setup. This is a very time consuming process, depending on the age of the OS and the quantity of updates released since the last service pack. You might want to do yourself a favor during development and disable this functionality, by commenting out the WITH WINDOWS UPDATES section and uncommenting the WITHOUT WINDOWS UPDATES section in Autounattend.xml:

<!-- WITHOUT WINDOWS UPDATES -->
<SynchronousCommand wcm:action="add">
    <CommandLine>cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\openssh.ps1 -AutoStart</CommandLine>
    <Description>Install OpenSSH</Description>
    <Order>99</Order>
    <RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand>
<!-- END WITHOUT WINDOWS UPDATES -->
<!-- WITH WINDOWS UPDATES -->
<!--
<SynchronousCommand wcm:action="add">
    <CommandLine>cmd.exe /c a:\microsoft-updates.bat</CommandLine>
    <Order>98</Order>
    <Description>Enable Microsoft Updates</Description>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
    <CommandLine>cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\openssh.ps1</CommandLine>
    <Description>Install OpenSSH</Description>
    <Order>99</Order>
    <RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
    <CommandLine>cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\win-updates.ps1</CommandLine>
    <Description>Install Windows Updates</Description>
    <Order>100</Order>
    <RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand>
-->
<!-- END WITH WINDOWS UPDATES -->

Doing so will give you hours back in your day, which is a good thing.

Windows 7 support

Windows 7 is going out of support in January 2020, and the scripts for building Windows 7 machines are only sporadically maintained.

Windows 7 was first released in 2009. This means there are a lot of updates available for Windows 7, and running Windows Updates on a Windows 7 box using the mechanism described above takes an extremely long time.

The Windows 7 templates therefore take a slightly different approach, first installing Service Pack 1, updating the servicing stack and then installing the latest update rollup, .NET 4.8 and PowerShell 5.1. Finally, any missing updates are installed using Ansible.

This means you'll need to install Ansible on your machine if you want to run the Windows 7 scripts. You can install ansible on a Linux machine.

If you want to run these scripts on a Windows machine, you can try to run Ansible in cygwin or Bash on Ubuntu on Windows. Alternatively, you can disable the ansible steps in the windows_7.json file. Make sure to manually run Windows Update if you do!

WinRM

These boxes use WinRM. There is no OpenSSH installed.

Hyper-V Support

If you are running Windows 10, Windows Server 2016 or later, then you can also use these packerfiles to build a Hyper-V virtual machine. I have the ISO already downloaded to save time, and only have Hyper-V installed on my laptop, so I run:

packer build --only hyperv-iso -var 'hyperv_switchname=Ethernet' -var 'iso_url=./server2016.iso' .\windows_2016_docker.json

Where Ethernet is the name of my default Hyper-V Virtual Switch. You then can use this box with Vagrant to spin up a Hyper-V VM.

Generation 2 VMs

Some of these images use Hyper-V "Generation 2" VMs to enable the latest features and faster booting. However, an extra manual step is needed to put the needed files into ISOs because Gen2 VMs don't support virtual floppy disks.

  • windows_server_insider.json
  • windows_server_insider_docker.json
  • windows_10_insider.json

Before running packer build, be sure to run ./make_unattend_iso.ps1 first. Otherwise the build will fail on a missing ISO file

hyperv-iso output will be in this color.

1 error(s) occurred:

* Secondary Dvd image does not exist: CreateFile ./iso/windows_server_insider_unattend.iso: The system cannot find the file specified.

KVM/qemu support

If you are using Linux and have KVM/qemu configured, you can use these packerfiles to build a KVM virtual machine. To build a KVM/qemu box, first make sure:

  • You are a member of the kvm group on your machine. You can list the groups you are member of by running groups. It should include the kvm group. If you're not a member, run sudo usermod -aG kvm $(whoami) to add yourself.
  • You have downloaded the iso image with the Windows drivers for paravirtualized KVM/qemu hardware. You can do this from the command line: wget -nv -nc https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso -O virtio-win.iso.

You can use the following sample command to build a KVM/qemu box:

packer build --only=qemu --var virtio_win_iso=./virtio-win.iso ./windows_2019_docker.json

Parallels support

In case you're using Parallels, you can now build the Windows Server 2019 with Docker VM.

Prerequisites:

You can use the following sample command to build a Parallels VM:

packer build --only=parallels-iso windows_2019_docker.json

The Parallels builder config turns efi boot off in order to use the same answer file like all the other builders. If you find you need to turn efi boot on then make sure to adjust the appropriate answer file, especially the section regarding the partitioning of the disk. If you need to further customize the VM, consult the documentation at https://www.packer.io/docs/builders/parallels-iso.html.

Using .box Files With Vagrant

The generated box files include a Vagrantfile template that is suitable for use with Vagrant 1.7.4+, but the latest version is always recommended.

Example Steps for Hyper-V:

vagrant box add windows_2016_docker windows_2016_docker_hyperv.box
vagrant init windows_2016_docker
vagrant up --provider hyperv

Contributing

Pull request are welcome!

You can’t perform that action at this time.