README.md 5.58 KB
Newer Older
Stefan Scherer's avatar
Stefan Scherer committed
1
# My Retina Windows Templates for Packer
Stefan Scherer's avatar
Stefan Scherer committed
2

Stefan Scherer's avatar
Stefan Scherer committed
3
[![Build status](https://ci.appveyor.com/api/projects/status/76pea1oexae5ca05?svg=true)](https://ci.appveyor.com/project/StefanScherer/packer-windows)
Joe Fitzgerald's avatar
Joe Fitzgerald committed
4

Joe Fitzgerald's avatar
Joe Fitzgerald committed
5 6
### Introduction

Stefan Scherer's avatar
Stefan Scherer committed
7 8 9
This repository contains Windows templates that can be used to create boxes for
Vagrant using Packer ([Website](https://www.packer.io))
([Github](https://github.com/mitchellh/packer)).
Joe Fitzgerald's avatar
Joe Fitzgerald committed
10

Stefan Scherer's avatar
Stefan Scherer committed
11 12 13
This repo is a modified fork of the popular
[joefitzgerald/packer-windows](https://github.com/joefitzgerald/packer-windows)
repo.
Stefan Scherer's avatar
Stefan Scherer committed
14 15 16 17 18

Some of my enhancements are:

* Support of fullscreen Retina display on a MacBook Pro.
* WinRM, no more OpenSSH
Stefan Scherer's avatar
Stefan Scherer committed
19
* PowerShell attached to taskbar in desktop editions
Joe Fitzgerald's avatar
Joe Fitzgerald committed
20

21 22
### Packer Version

Stefan Scherer's avatar
Stefan Scherer committed
23 24
[Packer](https://github.com/mitchellh/packer/blob/master/CHANGELOG.md) `1.1.2`
or greater is recommended.
25

26 27
### Windows Versions

Stefan Scherer's avatar
Stefan Scherer committed
28 29
The following Windows versions are known to work (built with VMware Fusion Pro
10.0.1):
30

Stefan Scherer's avatar
Stefan Scherer committed
31 32 33
* Windows 10
  * Windows 10 1709
  * Windows 10 Insider
Stefan Scherer's avatar
Stefan Scherer committed
34 35
* Windows Server 2016 Desktop
* Windows Server Core
Stefan Scherer's avatar
Stefan Scherer committed
36 37 38
  * Windows Server 2016 without and with Docker
  * Windows Server 1709 without and with Docker
  * Windows Server Insider without and with Docker
Stefan Scherer's avatar
Stefan Scherer committed
39

Stefan Scherer's avatar
Stefan Scherer committed
40 41
You may find other packer template files, but older versions of Windows doesn't
work so nice with a Retina display.
42 43 44

### Windows Editions

Stefan Scherer's avatar
Stefan Scherer committed
45 46 47 48
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).
49 50 51

### Product Keys

Stefan Scherer's avatar
Stefan Scherer committed
52 53 54 55
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:
56 57 58 59

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

Stefan Scherer's avatar
Stefan Scherer committed
60 61 62
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.
63

64
### Using existing ISOs
Stefan Scherer's avatar
Stefan Scherer committed
65 66 67 68 69 70

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)
71 72

```
Stefan Scherer's avatar
Stefan Scherer committed
73
packer build -var 'iso_url=./server2016.iso' .\windows_2016.json
74 75
```

76 77
### Windows Updates

Stefan Scherer's avatar
Stefan Scherer committed
78 79 80 81 82 83
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`:
84

85 86 87
```xml
<!-- WITHOUT WINDOWS UPDATES -->
<SynchronousCommand wcm:action="add">
88 89 90 91
    <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>
92 93 94 95
</SynchronousCommand>
<!-- END WITHOUT WINDOWS UPDATES -->
<!-- WITH WINDOWS UPDATES -->
<!--
Brett Porter's avatar
Brett Porter committed
96 97 98 99 100
<SynchronousCommand wcm:action="add">
    <CommandLine>cmd.exe /c a:\microsoft-updates.bat</CommandLine>
    <Order>98</Order>
    <Description>Enable Microsoft Updates</Description>
</SynchronousCommand>
101
<SynchronousCommand wcm:action="add">
102 103 104 105
    <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>
106
</SynchronousCommand>
107
<SynchronousCommand wcm:action="add">
108 109 110 111
    <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>
112
</SynchronousCommand>
113 114
-->
<!-- END WITH WINDOWS UPDATES -->
115 116 117 118
```

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

Stefan Scherer's avatar
Stefan Scherer committed
119
### WinRM
120

Stefan Scherer's avatar
Stefan Scherer committed
121
These boxes use WinRM. There is no OpenSSH installed.
122

123
### Hyper-V Support
Stefan Scherer's avatar
Stefan Scherer committed
124 125 126 127 128

If you are running Windows 10, 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:

Patrick Lang's avatar
Patrick Lang committed
129
```
Stefan Scherer's avatar
Stefan Scherer committed
130
packer build --only hyperv-iso -var 'hyperv_switchname=Ethernet' -var 'iso_url=./server2016.iso' .\windows_2016_docker.json
Patrick Lang's avatar
Patrick Lang committed
131 132
```

Stefan Scherer's avatar
Stefan Scherer committed
133 134 135 136
You then can use this box with Vagrant to spin up a Hyper-V VM. Vagrant
currently needs some patches as well, see the script
[install-vagrant.ps1](hyperv/scripts/install-vagrant.ps1) how to patch Vagrant
1.8.4 to fix these issues.
137

138 139
### Using .box Files With Vagrant

Stefan Scherer's avatar
Stefan Scherer committed
140 141 142
The generated box files include a Vagrantfile template that is suitable for use
with Vagrant 1.7.4+, which includes native support for Windows and uses WinRM to
communicate with the box.
143

Patrick Lang's avatar
Patrick Lang committed
144
Vagrant 1.8.4 does need some workarounds though:
Stefan Scherer's avatar
Stefan Scherer committed
145 146 147 148 149

* There is a bug in get_vm_status.ps1
* winrm-fs needs an update as well See:
  https://github.com/PatrickLang/packer-windows/issues/1#issuecomment-230151622
  These are fixed in 1.8.5, so upgrading is easiest.
Patrick Lang's avatar
Patrick Lang committed
150

151
Example Steps for Hyper-V:
Stefan Scherer's avatar
Stefan Scherer committed
152

153
```
Stefan Scherer's avatar
Stefan Scherer committed
154 155
vagrant box add windows_2016_docker windows_2016_docker_hyperv.box
vagrant init windows_2016_docker
156
vagrant up --provider hyperv
157
```
Patrick Lang's avatar
Patrick Lang committed
158

Joe Fitzgerald's avatar
Joe Fitzgerald committed
159 160
### Contributing

Stefan Scherer's avatar
Stefan Scherer committed
161
Pull requests welcomed, but normally should go to Joe's repo.