-
Notifications
You must be signed in to change notification settings - Fork 97
/
windows-2012-r2.pkr.hcl
227 lines (202 loc) · 6.25 KB
/
windows-2012-r2.pkr.hcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
packer {
required_plugins {
windows-update = {
version = "0.14.0"
source = "github.com/rgl/windows-update"
}
}
}
variable "disk_size" {
type = string
default = "40960"
}
variable "iso_url" {
type = string
default = "http://download.microsoft.com/download/6/2/A/62A76ABB-9990-4EFC-A4FE-C7D698DAEB96/9600.17050.WINBLUE_REFRESH.140317-1640_X64FRE_SERVER_EVAL_EN-US-IR3_SSS_X64FREE_EN-US_DV9.ISO"
}
variable "iso_checksum" {
type = string
default = "sha256:6612b5b1f53e845aacdf96e974bb119a3d9b4dcb5b82e65804ab7e534dc7b4d5"
}
variable "hyperv_switch_name" {
type = string
default = env("HYPERV_SWITCH_NAME")
}
variable "hyperv_vlan_id" {
type = string
default = env("HYPERV_VLAN_ID")
}
variable "vagrant_box" {
type = string
}
source "qemu" "windows-2012-r2-amd64" {
accelerator = "kvm"
cpus = 2
memory = 4096
qemuargs = [
["-cpu", "host"],
["-soundhw", "hda"],
["-device", "piix3-usb-uhci"],
["-device", "usb-tablet"],
["-device", "virtio-scsi-pci,id=scsi0"],
["-device", "scsi-hd,bus=scsi0.0,drive=drive0"],
["-device", "virtio-net,netdev=user.0"],
["-vga", "qxl"],
["-device", "virtio-serial-pci"],
["-chardev", "socket,path=/tmp/{{ .Name }}-qga.sock,server,nowait,id=qga0"],
["-device", "virtserialport,chardev=qga0,name=org.qemu.guest_agent.0"],
["-chardev", "spicevmc,id=spicechannel0,name=vdagent"],
["-device", "virtserialport,chardev=spicechannel0,name=com.redhat.spice.0"],
["-spice", "unix,addr=/tmp/{{ .Name }}-spice.socket,disable-ticketing"],
]
disk_interface = "virtio-scsi"
disk_cache = "unsafe"
disk_discard = "unmap"
disk_size = var.disk_size
floppy_files = [
"windows-2012-r2/autounattend.xml",
"winrm.ps1",
"provision-openssh.ps1",
"drivers/viostor/2k12R2/amd64/*.cat",
"drivers/viostor/2k12R2/amd64/*.inf",
"drivers/viostor/2k12R2/amd64/*.sys",
"drivers/vioscsi/2k12R2/amd64/*.cat",
"drivers/vioscsi/2k12R2/amd64/*.inf",
"drivers/vioscsi/2k12R2/amd64/*.sys",
"drivers/NetKVM/2k12R2/amd64/*.cat",
"drivers/NetKVM/2k12R2/amd64/*.inf",
"drivers/NetKVM/2k12R2/amd64/*.sys",
"drivers/qxldod/2k12R2/amd64/*.cat",
"drivers/qxldod/2k12R2/amd64/*.inf",
"drivers/qxldod/2k12R2/amd64/*.sys",
]
format = "qcow2"
headless = true
http_directory = "."
iso_url = var.iso_url
iso_checksum = var.iso_checksum
shutdown_command = "shutdown /s /t 0 /f /d p:4:1 /c \"Packer Shutdown\""
communicator = "ssh"
ssh_username = "vagrant"
ssh_password = "vagrant"
ssh_timeout = "4h"
}
source "virtualbox-iso" "windows-2012-r2-amd64" {
cpus = 2
memory = 4096
disk_size = var.disk_size
floppy_files = [
"windows-2012-r2/autounattend.xml",
"winrm.ps1",
"provision-openssh.ps1",
]
guest_additions_interface = "sata"
guest_additions_mode = "attach"
guest_os_type = "Windows81_64"
hard_drive_interface = "sata"
headless = true
iso_url = var.iso_url
iso_checksum = var.iso_checksum
iso_interface = "sata"
shutdown_command = "shutdown /s /t 0 /f /d p:4:1 /c \"Packer Shutdown\""
vboxmanage = [
["storagectl", "{{ .Name }}", "--name", "IDE Controller", "--remove"],
["modifyvm", "{{ .Name }}", "--vrde", "off"],
["modifyvm", "{{ .Name }}", "--graphicscontroller", "vboxsvga"],
["modifyvm", "{{ .Name }}", "--vram", "128"],
["modifyvm", "{{ .Name }}", "--accelerate3d", "on"],
["modifyvm", "{{ .Name }}", "--usb", "on"],
["modifyvm", "{{ .Name }}", "--mouse", "usbtablet"],
["modifyvm", "{{ .Name }}", "--audio", "none"],
["modifyvm", "{{ .Name }}", "--nictype1", "82540EM"],
["modifyvm", "{{ .Name }}", "--nictype2", "82540EM"],
["modifyvm", "{{ .Name }}", "--nictype3", "82540EM"],
["modifyvm", "{{ .Name }}", "--nictype4", "82540EM"],
]
communicator = "ssh"
ssh_username = "vagrant"
ssh_password = "vagrant"
ssh_timeout = "4h"
}
source "hyperv-iso" "windows-2012-r2-amd64" {
cpus = 2
memory = 4096
generation = 2
boot_command = ["<up><wait><up><wait><up><wait><up><wait><up><wait>"]
boot_order = ["SCSI:0:0"]
boot_wait = "1s"
cd_files = [
"windows-2012-r2-uefi/autounattend.xml",
"winrm.ps1",
"provision-openssh.ps1",
]
disk_size = var.disk_size
first_boot_device = "DVD"
headless = true
iso_url = var.iso_url
iso_checksum = var.iso_checksum
switch_name = var.hyperv_switch_name
temp_path = "tmp"
vlan_id = var.hyperv_vlan_id
shutdown_command = "shutdown /s /t 0 /f /d p:4:1 /c \"Packer Shutdown\""
communicator = "ssh"
ssh_username = "vagrant"
ssh_password = "vagrant"
ssh_timeout = "4h"
}
build {
sources = [
"source.qemu.windows-2012-r2-amd64",
"source.virtualbox-iso.windows-2012-r2-amd64",
"source.hyperv-iso.windows-2012-r2-amd64",
]
provisioner "powershell" {
script = "disable-windows-updates.ps1"
}
provisioner "powershell" {
inline = ["Uninstall-WindowsFeature FS-SMB1"]
}
provisioner "powershell" {
only = ["virtualbox-iso.windows-2012-r2-amd64"]
script = "virtualbox-prevent-vboxsrv-resolution-delay.ps1"
}
provisioner "powershell" {
script = "provision-powershell.ps1"
}
provisioner "powershell" {
only = ["qemu.windows-2012-r2-amd64"]
script = "provision-guest-tools-qemu-kvm.ps1"
}
provisioner "windows-restart" {
}
provisioner "powershell" {
only = ["qemu.windows-2012-r2-amd64"]
script = "libvirt-fix-cpu-driver.ps1"
}
provisioner "powershell" {
script = "provision.ps1"
}
provisioner "windows-update" {
filters = [
"include:$_.Title -like '*Servicing Stack Update for Windows*'",
]
}
provisioner "windows-update" {
}
provisioner "powershell" {
script = "enable-remote-desktop.ps1"
}
provisioner "powershell" {
script = "provision-cloudbase-init.ps1"
}
provisioner "powershell" {
script = "eject-media.ps1"
}
provisioner "powershell" {
script = "optimize.ps1"
}
post-processor "vagrant" {
output = var.vagrant_box
vagrantfile_template = "Vagrantfile.template"
}
}