forked from rgl/windows-vagrant
-
Notifications
You must be signed in to change notification settings - Fork 0
/
windows-2016.pkr.hcl
236 lines (211 loc) · 6.45 KB
/
windows-2016.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
228
229
230
231
232
233
234
235
236
packer {
required_plugins {
windows-update = {
version = "0.14.0"
source = "github.com/rgl/windows-update"
}
}
}
variable "disk_size" {
type = string
default = "61440"
}
variable "iso_url" {
type = string
default = "https://software-download.microsoft.com/download/pr/Windows_Server_2016_Datacenter_EVAL_en-us_14393_refresh.ISO"
}
variable "iso_checksum" {
type = string
default = "sha256:1ce702a578a3cb1ac3d14873980838590f06d5b7101c5daaccbac9d73f1fb50f"
}
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-2016-amd64" {
accelerator = "kvm"
cpus = 2
memory = 6144
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-2016/autounattend.xml",
"winrm.ps1",
"provision-powershell.ps1",
"provision-psremoting.ps1",
"provision-openssh.ps1",
"drivers/vioserial/2k16/amd64/*.cat",
"drivers/vioserial/2k16/amd64/*.inf",
"drivers/vioserial/2k16/amd64/*.sys",
"drivers/viostor/2k16/amd64/*.cat",
"drivers/viostor/2k16/amd64/*.inf",
"drivers/viostor/2k16/amd64/*.sys",
"drivers/vioscsi/2k16/amd64/*.cat",
"drivers/vioscsi/2k16/amd64/*.inf",
"drivers/vioscsi/2k16/amd64/*.sys",
"drivers/NetKVM/2k16/amd64/*.cat",
"drivers/NetKVM/2k16/amd64/*.inf",
"drivers/NetKVM/2k16/amd64/*.sys",
"drivers/qxldod/2k16/amd64/*.cat",
"drivers/qxldod/2k16/amd64/*.inf",
"drivers/qxldod/2k16/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-2016-amd64" {
cpus = 2
memory = 6144
disk_size = var.disk_size
floppy_files = [
"windows-2016/autounattend.xml",
"winrm.ps1",
"provision-powershell.ps1",
"provision-psremoting.ps1",
"provision-openssh.ps1",
]
guest_additions_interface = "sata"
guest_additions_mode = "attach"
guest_os_type = "Windows2016_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-2016-amd64" {
cpus = 2
memory = 6144
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-2016-uefi/autounattend.xml",
"winrm.ps1",
"provision-powershell.ps1",
"provision-psremoting.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-2016-amd64",
"source.virtualbox-iso.windows-2016-amd64",
"source.hyperv-iso.windows-2016-amd64",
]
provisioner "powershell" {
script = "disable-windows-updates.ps1"
}
provisioner "powershell" {
script = "disable-windows-defender.ps1"
}
provisioner "powershell" {
inline = ["Uninstall-WindowsFeature FS-SMB1"]
}
provisioner "powershell" {
only = ["virtualbox-iso.windows-2016-amd64"]
script = "virtualbox-prevent-vboxsrv-resolution-delay.ps1"
}
provisioner "powershell" {
only = ["qemu.windows-2016-amd64"]
script = "provision-guest-tools-qemu-kvm.ps1"
}
provisioner "windows-restart" {
}
provisioner "powershell" {
only = ["qemu.windows-2016-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"
}
}