-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathwindows.pkr.hcl
180 lines (145 loc) · 3.54 KB
/
windows.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
packer {
required_plugins {
vsphere = {
version = ">= 0.0.1"
source = "github.com/hashicorp/vsphere"
}
# if you would like to automatically install window updates, then uncomment
# the following section. Please also uncomment Line 163-170
# windows-update = {
# version = "0.14.0"
# source = "github.com/rgl/windows-update"
# }
}
}
variable "autounattend_file" {
type = string
default = ""
}
variable "cpu_num" {
type = number
default = 2
}
variable "disk_size" {
type = number
default = 102400
}
variable "mem_size" {
type = number
default = 4096
}
variable "os_iso_checksum" {
type = string
default = ""
}
variable "os_iso_url" {
type = string
default = ""
}
variable "vmtools_iso_path" {
type = string
default = ""
}
variable "floppy_pvscsi" {
type = string
default = ""
}
variable "vsphere_datastore" {
type = string
default = ""
}
variable "vsphere_datacenter" {
type = string
default = ""
}
variable "vsphere_guest_os_type" {
type = string
default = ""
}
variable "vsphere_host" {
type = string
default = ""
}
variable "vsphere_password" {
type = string
default = ""
sensitive = true
}
variable "vsphere_network" {
type = string
default = ""
}
variable "vsphere_server" {
type = string
default = ""
}
variable "vsphere_vm_name" {
type = string
default = ""
}
variable "vsphere_username" {
type = string
default = ""
}
variable "winrm_password" {
type = string
default = ""
sensitive = true
}
variable "winrm_username" {
type = string
default = ""
}
source "vsphere-iso" "windows" {
vcenter_server = "${var.vsphere_server}"
host = "${var.vsphere_host}"
username = "${var.vsphere_username}"
password = "${var.vsphere_password}"
insecure_connection = "true"
datacenter = "${var.vsphere_datacenter}"
datastore = "${var.vsphere_datastore}"
CPUs = "${var.cpu_num}"
RAM = "${var.mem_size}"
RAM_reserve_all = true
disk_controller_type = ["pvscsi"]
# firmware = "bios"
floppy_files = ["${var.autounattend_file}", "setup/setup.ps1", "setup/vmtools.cmd", "setup/appx.ps1"]
floppy_img_path = "${var.floppy_pvscsi}"
guest_os_type = "${var.vsphere_guest_os_type}"
iso_checksum = "${var.os_iso_checksum}"
iso_url = "${var.os_iso_url}"
iso_paths = ["${var.vmtools_iso_path}"]
network_adapters {
network = "${var.vsphere_network}"
network_card = "vmxnet3"
}
storage {
disk_size = "${var.disk_size}"
disk_thin_provisioned = true
}
vm_name = "${var.vsphere_vm_name}"
convert_to_template = "true"
communicator = "winrm"
winrm_username = "${var.winrm_username}"
winrm_password = "${var.winrm_password}"
winrm_timeout = "3h"
shutdown_timeout = "60m"
ip_wait_timeout = "3h"
ip_settle_timeout = "2m"
}
build {
sources = ["source.vsphere-iso.windows"]
# if you would like to automatically install window updates, then uncomment
# the following section. Please also uncomment Line 11-14
# provisioner "windows-update" {
# search_criteria = "IsInstalled=0"
# filters = [
# "exclude:$_.Title -like '*Preview*'",
# "include:$true",
# ]
# update_limit = 25
# }
provisioner "windows-shell" {
inline = ["dir c:\\"]
}
}