-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathws2022.pkr.hcl
107 lines (87 loc) · 2.49 KB
/
ws2022.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
packer {
required_plugins {
vsphere = {
version = ">= 0.0.1"
source = "github.com/hashicorp/vsphere"
}
}
}
source "vsphere-iso" "ws2022" {
# Deployment Connection Details
vcenter_server = "${var.vcenter_server}"
username = "${var.vcenter_user}"
password = "${var.vcenter_password}"
datacenter = "${var.vcenter_datacenter}"
cluster = "${var.vcenter_cluster}"
host = "${var.esx_host}"
datastore = "${var.vcenter_datastore}"
http_ip = "${var.http_ip}"
http_directory = "./resources"
insecure_connection = true
# VM Details
vm_name = "${var.vm_name}"
vm_version = 18
guest_os_type = "windows2019srvNext_64Guest"
CPUs = "${var.numcores}"
cpu_cores = "${var.numcores}"
RAM = "${var.memsize}"
firmware = "efi"
disk_controller_type = ["pvscsi"]
network_adapters {
network = "VM Network"
network_card = "vmxnet3"
}
storage {
disk_size = "${var.disk_size}"
disk_thin_provisioned = true
}
notes = "${var.vm_notes}"
remove_cdrom = true
# Boot details
iso_checksum = "${var.iso_checksum}"
iso_paths = ["[] /vmimages/tools-isoimages/windows.iso"]
iso_url = "${var.iso_url}"
boot_wait = "${var.boot_wait}"
boot_command = var.boot_command
cd_files = ["resources/configs/autounattend.xml", "resources/configs/sysprep-autounattend.xml", "resources/scripts/install-vmware-tools-from-iso.ps1"]
# OS Connection Details
communicator = "ssh"
ssh_clear_authorized_keys = true
ssh_password = "${var.os_password}"
ssh_timeout = "1h"
ssh_username = "${var.os_user}"
shutdown_command = "C:\\Windows\\system32\\Sysprep\\sysprep.exe /generalize /oobe /shutdown /unattend:F:\\sysprep-autounattend.xml"
shutdown_timeout = "60m"
export {
force = true
output_directory = "./build"
options = ["nodevicesubtypes"]
}
}
build {
name = "ws2022"
sources = ["source.vsphere-iso.ws2022"]
provisioner "powershell" {
scripts = ["resources/scripts/win-update.ps1"]
valid_exit_codes = [0, 2300218]
}
provisioner "windows-restart" {
pause_before = "30s"
restart_timeout = "30m"
}
provisioner "powershell" {
scripts = ["resources/scripts/win-update.ps1"]
}
provisioner "windows-restart" {
restart_timeout = "30m"
}
provisioner "powershell" {
scripts = ["resources/scripts/adjustments.ps1"]
}
provisioner "powershell" {
scripts = ["resources/scripts/cleanup.ps1"]
}
provisioner "windows-restart" {
restart_timeout = "30m"
}
}