forked from rgl/windows-vagrant
-
Notifications
You must be signed in to change notification settings - Fork 0
/
windows-2019-vsphere.pkr.hcl
159 lines (138 loc) · 3.64 KB
/
windows-2019-vsphere.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
packer {
required_plugins {
# see https://github.com/rgl/packer-plugin-windows-update
windows-update = {
version = "0.14.3"
source = "github.com/rgl/windows-update"
}
# see https://github.com/hashicorp/packer-plugin-vsphere
vsphere = {
version = "1.2.1"
source = "github.com/hashicorp/vsphere"
}
}
}
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-2019-amd64" {
CPUs = 4
RAM = 4096
guest_os_type = "windows9Server64Guest"
floppy_files = [
"provision-autounattend.ps1",
"provision-openssh.ps1",
"provision-psremoting.ps1",
"provision-pwsh.ps1",
"provision-vmtools.ps1",
"provision-winrm.ps1",
"tmp/windows-2019-vsphere/autounattend.xml",
]
iso_paths = [
"[${var.vsphere_datastore}] iso/windows-2019-17763.737.190906-2324.rs5_release_svc_refresh_SERVER_EVAL_x64FRE_en-us_1.iso",
"[${var.vsphere_datastore}] iso/VMware-tools-windows-12.0.0-19345655.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-2019-amd64-vsphere"
shutdown_command = "shutdown /s /t 0 /f /d p:4:1 /c \"Packer Shutdown\""
communicator = "ssh"
ssh_password = "vagrant"
ssh_username = "vagrant"
ssh_timeout = "4h"
ssh_file_transfer_method = "sftp"
}
build {
sources = ["source.vsphere-iso.windows-2019-amd64"]
provisioner "powershell" {
use_pwsh = true
script = "disable-windows-updates.ps1"
}
provisioner "powershell" {
use_pwsh = true
script = "disable-windows-defender.ps1"
}
provisioner "windows-restart" {
}
provisioner "powershell" {
use_pwsh = true
script = "provision.ps1"
}
provisioner "windows-update" {
filters = [
"exclude:$_.Title -like '*VMware*'",
"include:$true"
]
}
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"
}
}