-
Notifications
You must be signed in to change notification settings - Fork 111
Expand file tree
/
Copy pathwindows-2025-uefi-vsphere.pkr.hcl
More file actions
187 lines (162 loc) · 4.42 KB
/
Copy pathwindows-2025-uefi-vsphere.pkr.hcl
File metadata and controls
187 lines (162 loc) · 4.42 KB
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
packer {
required_plugins {
# see https://github.com/rgl/packer-plugin-windows-update
windows-update = {
version = "0.18.4"
source = "github.com/rgl/windows-update"
}
# see https://github.com/vmware/packer-plugin-vsphere
vsphere = {
version = "2.4.0"
source = "github.com/vmware/vsphere"
}
}
}
variable "iso_url" {
type = string
default = env("WINDOWS_2025_ISO_URL")
}
variable "vsphere_disk_size" {
type = string
default = "61440"
}
variable "vsphere_host" {
type = string
default = env("GOVC_HOST")
}
variable "vsphere_username" {
type = string
default = env("GOVC_USERNAME")
}
variable "vsphere_password" {
type = string
default = env("GOVC_PASSWORD")
sensitive = true
}
variable "vsphere_esxi_host" {
type = string
default = env("VSPHERE_ESXI_HOST")
}
variable "vsphere_datacenter" {
type = string
default = env("GOVC_DATACENTER")
}
variable "vsphere_cluster" {
type = string
default = env("GOVC_CLUSTER")
}
variable "vsphere_datastore" {
type = string
default = env("GOVC_DATASTORE")
}
variable "vsphere_folder" {
type = string
default = env("VSPHERE_TEMPLATE_FOLDER")
}
variable "vsphere_network" {
type = string
default = env("VSPHERE_VLAN")
}
source "vsphere-iso" "windows-2025-uefi-amd64" {
firmware = "efi"
CPUs = 4
RAM = 4096
guest_os_type = "windows2019srvNext_64Guest"
cd_label = "PROVISION"
cd_files = [
"provision-autounattend.ps1",
"provision-openssh.ps1",
"provision-psremoting.ps1",
"provision-pwsh.ps1",
"provision-vmtools.ps1",
"provision-winrm.ps1",
"tmp/windows-2025-uefi-vsphere/autounattend.xml",
]
iso_paths = [
"[${var.vsphere_datastore}] iso/windows-2025-${basename(var.iso_url)}",
"[${var.vsphere_datastore}] iso/VMware-tools-windows-13.1.0-25218885.iso",
]
network_adapters {
network = var.vsphere_network
network_card = "vmxnet3"
}
disk_controller_type = ["pvscsi"]
storage {
disk_size = var.vsphere_disk_size
disk_thin_provisioned = true
}
convert_to_template = false
insecure_connection = true
vcenter_server = var.vsphere_host
username = var.vsphere_username
password = var.vsphere_password
host = var.vsphere_esxi_host
datacenter = var.vsphere_datacenter
cluster = var.vsphere_cluster
datastore = var.vsphere_datastore
folder = var.vsphere_folder
vm_name = "windows-2025-uefi-amd64-vsphere"
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>"]
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.vsphere-iso.windows-2025-uefi-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-recovery-partition.ps1"
}
provisioner "windows-restart" {
}
provisioner "powershell" {
use_pwsh = true
script = "provision.ps1"
}
provisioner "windows-update" {
filters = [
# exclude KB5007651:
# Update for Windows Security platform - KB5007651 (Version 10.0.29510.1001)
# NB it can only be applied while the user is logged in.
"exclude:$_.Title -like '*KB5007651*'",
"exclude:$_.Title -like '*VMware*'",
"include:$true"
]
}
provisioner "powershell" {
use_pwsh = true
script = "optimize-cleanup-image.ps1"
}
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 = "provision-lock-screen-background.ps1"
}
provisioner "powershell" {
use_pwsh = true
script = "eject-media.ps1"
}
provisioner "powershell" {
use_pwsh = true
script = "optimize.ps1"
}
}