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

Joe Fitzgerald's avatar
Joe Fitzgerald committed
3 4
### Introduction

Stefan Scherer's avatar
Stefan Scherer committed
5
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
6

Stefan Scherer's avatar
Stefan Scherer committed
7 8 9 10 11 12
This repo is a modified fork of the popular [joefitzgerald/packer-windows](https://github.com/joefitzgerald/packer-windows) repo.

Some of my enhancements are:

* Support of fullscreen Retina display on a MacBook Pro.
* WinRM, no more OpenSSH
13
* PowerShell attached to taskbar with new features enabled
Joe Fitzgerald's avatar
Joe Fitzgerald committed
14

15 16
### Packer Version

Stefan Scherer's avatar
Stefan Scherer committed
17
[Packer](https://github.com/mitchellh/packer/blob/master/CHANGELOG.md) `0.10.0` or greater is required.
18

19 20
### Windows Versions

Stefan Scherer's avatar
Stefan Scherer committed
21
The following Windows versions are known to work (built with VMware Fusion Pro 8.1.1):
22

Stefan Scherer's avatar
Stefan Scherer committed
23
 * Windows 10
Stefan Scherer's avatar
Stefan Scherer committed
24 25
 * Windows Server 2016 TP5
 * Windows Server 2016 TP5 with Hyper-V and Docker -> see [docker-windows-box](https://github.com/StefanScherer/docker-windows-box) for an use case
Stefan Scherer's avatar
Stefan Scherer committed
26 27

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

### Windows Editions

31 32 33 34
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).

### Product Keys

Joe Fitzgerald's avatar
Joe Fitzgerald committed
35
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:
36 37 38 39 40

* 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.
41

42 43 44 45 46 47 48 49 50
### 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=./server2016tp5.iso' .\windows_2016.json
```

51 52
### Windows Updates

53
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`:
54

55 56 57
```xml
<!-- WITHOUT WINDOWS UPDATES -->
<SynchronousCommand wcm:action="add">
58 59 60 61
    <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>
62 63 64 65
</SynchronousCommand>
<!-- END WITHOUT WINDOWS UPDATES -->
<!-- WITH WINDOWS UPDATES -->
<!--
Brett Porter's avatar
Brett Porter committed
66 67 68 69 70
<SynchronousCommand wcm:action="add">
    <CommandLine>cmd.exe /c a:\microsoft-updates.bat</CommandLine>
    <Order>98</Order>
    <Description>Enable Microsoft Updates</Description>
</SynchronousCommand>
71
<SynchronousCommand wcm:action="add">
72 73 74 75
    <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>
76
</SynchronousCommand>
77
<SynchronousCommand wcm:action="add">
78 79 80 81
    <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>
82
</SynchronousCommand>
83 84
-->
<!-- END WITH WINDOWS UPDATES -->
85 86 87 88
```

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

Stefan Scherer's avatar
Stefan Scherer committed
89
### WinRM
90

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

Stefan Scherer's avatar
Stefan Scherer committed
93 94
### Hyper-V Support
If you are running Windows 10, then you can also use these packerfiles to build a Hyper-V virtual machine:
95 96 97 98 99 100 101

This requires @taliesens [fork of Packer](https://github.com/mitchellh/packer/pull/2576) with Hyper-V support. The linked PR also has binaries available ex: https://dl.bintray.com/taliesins/Packer/Packer.1.0.0.104-HyperV.nupkg

Then run Packer:
```
packer build -var 'hyperv_switchname=Wifi' .\windows_2016.json
```
Stefan Scherer's avatar
Stefan Scherer committed
102
Be sure to set hyperv_switchname to an external Hyper-V switch.
103

Stefan Scherer's avatar
Stefan Scherer committed
104 105 106
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.
107

108 109
### Using .box Files With Vagrant

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

114 115 116 117 118 119 120 121 122
For Vagrant 1.7.4 you should update some Ruby gems with

```
vagrant plugin install winrm
vagrant plugin install winrm-fs
```

Vagrant 1.8+ will have these gems already preinstalled.

123 124 125 126 127 128 129 130 131 132 133 134 135 136
Example Steps:
```
vagrant init
vagrant box add windows_2016_docker_hyperv.box --name Windows2016Docker
```
Edit Vagrantfile to refer to it
```
Vagrant.configure("2") do |config|
  config.vm.box = "Windows2016Docker"

```
vagrant up 


Joe Fitzgerald's avatar
Joe Fitzgerald committed
137 138
### Contributing

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