-
Notifications
You must be signed in to change notification settings - Fork 96
/
windows-11-24h2.pkr.hcl
296 lines (273 loc) · 8.31 KB
/
windows-11-24h2.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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
packer {
required_plugins {
# see https://github.com/hashicorp/packer-plugin-qemu
qemu = {
version = "1.1.0"
source = "github.com/hashicorp/qemu"
}
# see https://github.com/hashicorp/packer-plugin-proxmox
proxmox = {
version = "1.1.8"
source = "github.com/hashicorp/proxmox"
}
# see https://github.com/hashicorp/packer-plugin-hyperv
hyperv = {
version = "1.1.3"
source = "github.com/hashicorp/hyperv"
}
# see https://github.com/hashicorp/packer-plugin-vagrant
vagrant = {
version = "1.1.5"
source = "github.com/hashicorp/vagrant"
}
# see https://github.com/rgl/packer-plugin-windows-update
windows-update = {
version = "0.16.8"
source = "github.com/rgl/windows-update"
}
}
}
variable "disk_size" {
type = string
default = "61440"
}
variable "iso_url" {
type = string
default = "https://software-static.download.prss.microsoft.com/dbazure/888969d5-f34g-4e03-ac9d-1f9786c66749/26100.1742.240906-0331.ge_release_svc_refresh_CLIENT_LTSC_EVAL_x64FRE_en-us.iso"
}
variable "iso_checksum" {
type = string
default = "sha256:67cec5865eaa037a72ddc633a717a10a2bed50778862267223ddb9c60ef5da68"
}
variable "proxmox_node" {
type = string
default = env("PROXMOX_NODE")
}
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-11-24h2-amd64" {
accelerator = "kvm"
machine_type = "q35"
cpus = 2
memory = 4096
qemuargs = [
["-cpu", "host"],
["-device", "qemu-xhci"],
["-device", "virtio-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
cd_label = "PROVISION"
cd_files = [
"drivers/NetKVM/w11/amd64/*.cat",
"drivers/NetKVM/w11/amd64/*.inf",
"drivers/NetKVM/w11/amd64/*.sys",
"drivers/NetKVM/w11/amd64/*.exe",
"drivers/qxldod/w11/amd64/*.cat",
"drivers/qxldod/w11/amd64/*.inf",
"drivers/qxldod/w11/amd64/*.sys",
"drivers/vioscsi/w11/amd64/*.cat",
"drivers/vioscsi/w11/amd64/*.inf",
"drivers/vioscsi/w11/amd64/*.sys",
"drivers/vioserial/w11/amd64/*.cat",
"drivers/vioserial/w11/amd64/*.inf",
"drivers/vioserial/w11/amd64/*.sys",
"drivers/viostor/w11/amd64/*.cat",
"drivers/viostor/w11/amd64/*.inf",
"drivers/viostor/w11/amd64/*.sys",
"drivers/virtio-win-guest-tools.exe",
"provision-autounattend.ps1",
"provision-guest-tools-qemu-kvm.ps1",
"provision-openssh.ps1",
"provision-psremoting.ps1",
"provision-pwsh.ps1",
"provision-winrm.ps1",
"tmp/windows-11-24h2/autounattend.xml",
]
format = "qcow2"
headless = true
net_device = "virtio-net"
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"
ssh_file_transfer_method = "sftp"
}
source "proxmox-iso" "windows-11-24h2-amd64" {
template_name = "template-windows-11-24h2"
template_description = "See https://github.com/rgl/windows-vagrant"
tags = "windows-11-24h2;template"
insecure_skip_tls_verify = true
node = var.proxmox_node
machine = "q35"
cpu_type = "host"
cores = 2
memory = 4096
vga {
type = "qxl"
memory = 32
}
network_adapters {
model = "virtio"
bridge = "vmbr0"
}
scsi_controller = "virtio-scsi-single"
disks {
type = "scsi"
io_thread = true
ssd = true
discard = true
disk_size = "${var.disk_size}M"
storage_pool = "local-lvm"
}
iso_storage_pool = "local"
iso_url = var.iso_url
iso_checksum = var.iso_checksum
unmount_iso = true
additional_iso_files {
device = "ide0"
unmount = true
iso_storage_pool = "local"
cd_label = "PROVISION"
cd_files = [
"drivers/NetKVM/w11/amd64/*.cat",
"drivers/NetKVM/w11/amd64/*.inf",
"drivers/NetKVM/w11/amd64/*.sys",
"drivers/NetKVM/w11/amd64/*.exe",
"drivers/qxldod/w11/amd64/*.cat",
"drivers/qxldod/w11/amd64/*.inf",
"drivers/qxldod/w11/amd64/*.sys",
"drivers/vioscsi/w11/amd64/*.cat",
"drivers/vioscsi/w11/amd64/*.inf",
"drivers/vioscsi/w11/amd64/*.sys",
"drivers/vioserial/w11/amd64/*.cat",
"drivers/vioserial/w11/amd64/*.inf",
"drivers/vioserial/w11/amd64/*.sys",
"drivers/viostor/w11/amd64/*.cat",
"drivers/viostor/w11/amd64/*.inf",
"drivers/viostor/w11/amd64/*.sys",
"drivers/virtio-win-guest-tools.exe",
"provision-autounattend.ps1",
"provision-guest-tools-qemu-kvm.ps1",
"provision-openssh.ps1",
"provision-psremoting.ps1",
"provision-pwsh.ps1",
"provision-winrm.ps1",
"tmp/windows-11-24h2/autounattend.xml",
]
}
os = "win11"
ssh_username = "vagrant"
ssh_password = "vagrant"
ssh_timeout = "60m"
http_directory = "."
boot_wait = "30s"
}
source "hyperv-iso" "windows-11-24h2-amd64" {
cpus = 2
memory = 4096
generation = 2
boot_wait = "1s"
boot_command = ["<up><wait><up><wait><up><wait><up><wait><up><wait><up><wait><up><wait><up><wait><up><wait><up><wait>"]
boot_order = ["SCSI:0:0"]
cd_label = "PROVISION"
cd_files = [
"provision-autounattend.ps1",
"provision-openssh.ps1",
"provision-psremoting.ps1",
"provision-pwsh.ps1",
"provision-winrm.ps1",
"tmp/windows-11-24h2-uefi/autounattend.xml",
]
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"
ssh_file_transfer_method = "sftp"
}
build {
sources = [
"source.qemu.windows-11-24h2-amd64",
"source.proxmox-iso.windows-11-24h2-amd64",
"source.hyperv-iso.windows-11-24h2-amd64",
]
provisioner "powershell" {
use_pwsh = true
script = "disable-windows-updates.ps1"
}
provisioner "powershell" {
use_pwsh = true
script = "disable-windows-defender.ps1"
}
provisioner "powershell" {
use_pwsh = true
script = "remove-one-drive.ps1"
}
provisioner "powershell" {
use_pwsh = true
script = "remove-apps.ps1"
}
provisioner "windows-restart" {
}
provisioner "powershell" {
use_pwsh = true
script = "provision.ps1"
}
provisioner "windows-update" {
}
provisioner "powershell" {
use_pwsh = true
script = "enable-remote-desktop.ps1"
}
provisioner "powershell" {
use_pwsh = true
script = "provision-cloudbase-init.ps1"
}
provisioner "powershell" {
use_pwsh = true
script = "eject-media.ps1"
}
provisioner "powershell" {
use_pwsh = true
script = "optimize.ps1"
}
post-processor "vagrant" {
except = ["proxmox-iso.windows-11-24h2-amd64"]
output = var.vagrant_box
vagrantfile_template = "Vagrantfile.template"
}
}