Skip to content

Commit 0722e0b

Browse files
Merge pull request #41 from LennertMertens/feature/add-additional-params
Add advanced parameters
2 parents 321fcf8 + 022f4e5 commit 0722e0b

File tree

2 files changed

+129
-35
lines changed

2 files changed

+129
-35
lines changed

main.tf

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ resource "vsphere_virtual_machine" "Linux" {
9595
wait_for_guest_ip_timeout = var.wait_for_guest_ip_timeout
9696
wait_for_guest_net_timeout = var.wait_for_guest_net_timeout
9797

98+
ignored_guest_ips = var.ignored_guest_ips
99+
98100
dynamic "network_interface" {
99101
for_each = var.network_cards
100102
content {
@@ -155,6 +157,18 @@ resource "vsphere_virtual_machine" "Linux" {
155157
ipv4_gateway = var.vmgateway
156158
}
157159
}
160+
161+
// Advanced options
162+
hv_mode = var.hv_mode
163+
ept_rvi_mode = var.ept_rvi_mode
164+
nested_hv_enabled = var.nested_hv_enabled
165+
enable_logging = var.enable_logging
166+
cpu_performance_counters_enabled = var.cpu_performance_counters_enabled
167+
swap_placement_policy = var.swap_placement_policy
168+
latency_sensitivity = var.latency_sensitivity
169+
170+
shutdown_wait_timeout = var.shutdown_wait_timeout
171+
force_power_off = var.force_power_off
158172
}
159173

160174
resource "vsphere_virtual_machine" "Windows" {
@@ -191,6 +205,8 @@ resource "vsphere_virtual_machine" "Windows" {
191205
wait_for_guest_ip_timeout = var.wait_for_guest_ip_timeout
192206
wait_for_guest_net_timeout = var.wait_for_guest_net_timeout
193207

208+
ignored_guest_ips = var.ignored_guest_ips
209+
194210
dynamic "network_interface" {
195211
for_each = var.network_cards
196212
content {
@@ -261,4 +277,16 @@ resource "vsphere_virtual_machine" "Windows" {
261277
ipv4_gateway = var.vmgateway
262278
}
263279
}
280+
281+
// Advanced options
282+
hv_mode = var.hv_mode
283+
ept_rvi_mode = var.ept_rvi_mode
284+
nested_hv_enabled = var.nested_hv_enabled
285+
enable_logging = var.enable_logging
286+
cpu_performance_counters_enabled = var.cpu_performance_counters_enabled
287+
swap_placement_policy = var.swap_placement_policy
288+
latency_sensitivity = var.latency_sensitivity
289+
290+
shutdown_wait_timeout = var.shutdown_wait_timeout
291+
force_power_off = var.force_power_off
264292
}

variables.tf

Lines changed: 101 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
variable "vmname" {
2-
description = "The name of the virtual machine used to deploy the vms"
2+
description = "The name of the virtual machine used to deploy the vms."
33
default = "terraformvm"
44
}
55

66
variable "vmnamesuffix" {
7-
description = "vmname suffix after numbered index coming from instance variable"
7+
description = "vmname suffix after numbered index coming from instance variable."
88
default = ""
99
}
1010

1111
variable "vmnameliteral" {
12-
description = "vmname without any suffix or Prefix, only to be used for single instances"
12+
description = "vmname without any suffix or Prefix, only to be used for single instances."
1313
default = ""
1414
}
1515

1616
variable "vmtemp" {
17-
description = "Name of the template available in the vSphere"
17+
description = "Name of the template available in the vSphere."
1818
}
1919

2020
variable "instances" {
21-
description = "number of instances you want deploy from the template"
21+
description = "number of instances you want deploy from the template."
2222
default = 1
2323
}
2424

2525
variable "cpu_number" {
26-
description = "number of CPU (core per CPU) for the VM"
26+
description = "number of CPU (core per CPU) for the VM."
2727
default = 2
2828
}
2929

@@ -34,7 +34,7 @@ variable "cpu_reservation" {
3434

3535

3636
variable "ram_size" {
37-
description = "VM RAM size in megabytes"
37+
description = "VM RAM size in megabytes."
3838
default = 4096
3939
}
4040

@@ -44,22 +44,22 @@ variable "network_cards" {
4444
}
4545

4646
variable "ipv4" {
47-
description = "host(VM) IP address in map format, support more than one IP. Should correspond to number of instances"
47+
description = "host(VM) IP address in map format, support more than one IP. Should correspond to number of instances."
4848
type = map
4949
}
5050

5151
variable "ipv4submask" {
52-
description = "ipv4 Subnet mask"
52+
description = "ipv4 Subnet mask."
5353
type = list
5454
default = ["24"]
5555
}
5656

5757
variable "dc" {
58-
description = "Name of the datacenter you want to deploy the VM to"
58+
description = "Name of the datacenter you want to deploy the VM to."
5959
}
6060

6161
variable "vmrp" {
62-
description = "Cluster resource pool that VM will be deployed to. you use following to choose default pool in the cluster (esxi1) or (Cluster)/Resources"
62+
description = "Cluster resource pool that VM will be deployed to. you use following to choose default pool in the cluster (esxi1) or (Cluster)/Resources."
6363
}
6464

6565
variable "ds_cluster" {
@@ -79,7 +79,7 @@ variable "vmfolder" {
7979
}
8080

8181
variable "vmgateway" {
82-
description = "VM gateway to set during provisioning"
82+
description = "VM gateway to set during provisioning."
8383
default = null
8484
}
8585

@@ -108,7 +108,7 @@ variable "custom_attributes" {
108108
}
109109

110110
variable "extra_config" {
111-
description = "Extra configuration data for this virtual machine. Can be used to supply advanced parameters not normally in configuration, such as instance metadata.'disk.enableUUID', 'True'"
111+
description = "Extra configuration data for this virtual machine. Can be used to supply advanced parameters not normally in configuration, such as instance metadata.'disk.enableUUID', 'True'."
112112
type = map
113113
default = null
114114
}
@@ -171,31 +171,31 @@ variable "memory_reservation" {
171171
}
172172

173173
variable "disk_label" {
174-
description = "Storage data disk labels"
174+
description = "Storage data disk labels."
175175
type = list
176176
default = []
177177
}
178178

179179
variable "data_disk_label" {
180-
description = "Storage data disk labels"
180+
description = "Storage data disk labels."
181181
type = list
182182
default = []
183183
}
184184

185185
variable "data_disk_size_gb" {
186-
description = "List of Storage data disk size"
186+
description = "List of Storage data disk size."
187187
type = list
188188
default = []
189189
}
190190

191191
variable "disk_datastore" {
192-
description = "Define where the OS disk should be stored"
192+
description = "Define where the OS disk should be stored."
193193
type = string
194194
default = ""
195195
}
196196

197197
variable "data_disk_datastore" {
198-
description = "Define where the data disk should be stored, should be equal to number of defined data disks"
198+
description = "Define where the data disk should be stored, should be equal to number of defined data disks."
199199
type = list
200200
default = []
201201
# validation {
@@ -205,7 +205,7 @@ variable "data_disk_datastore" {
205205
}
206206

207207
variable "data_disk_scsi_controller" {
208-
description = "scsi_controller number for the data disk, should be equal to number of defined data disk"
208+
description = "scsi_controller number for the data disk, should be equal to number of defined data disk."
209209
type = list
210210
default = []
211211
# validation {
@@ -215,19 +215,19 @@ variable "data_disk_scsi_controller" {
215215
}
216216

217217
variable "scsi_bus_sharing" {
218-
description = "scsi_bus_sharing mode, acceptable values physicalSharing,virtualSharing,noSharing"
218+
description = "scsi_bus_sharing mode, acceptable values physicalSharing,virtualSharing,noSharing."
219219
type = string
220220
default = null
221221
}
222222

223223
variable "scsi_type" {
224-
description = "scsi_controller type, acceptable values lsilogic,pvscsi "
224+
description = "scsi_controller type, acceptable values lsilogic,pvscsi."
225225
type = string
226226
default = ""
227227
}
228228

229229
variable "scsi_controller" {
230-
description = "scsi_controller number for the main OS disk"
230+
description = "scsi_controller number for the main OS disk."
231231
type = number
232232
default = 0
233233
# validation {
@@ -255,20 +255,20 @@ variable "enable_disk_uuid" {
255255
}
256256

257257
variable "network_type" {
258-
description = "Define network type for each network interface"
258+
description = "Define network type for each network interface."
259259
type = list
260260
default = null
261261
}
262262

263263
#Linux Customization Variables
264264
variable "hw_clock_utc" {
265-
description = "Tells the operating system that the hardware clock is set to UTC"
265+
description = "Tells the operating system that the hardware clock is set to UTC."
266266
type = bool
267267
default = true
268268
}
269269

270270
variable "vmdomain" {
271-
description = "default VM domain for linux guest customization"
271+
description = "default VM domain for linux guest customization."
272272
default = "Development.com"
273273
}
274274

@@ -281,7 +281,7 @@ variable "is_windows_image" {
281281
}
282282

283283
variable "local_adminpass" {
284-
description = "The administrator password for this virtual machine.(Required) when using join_windomain option"
284+
description = "The administrator password for this virtual machine.(Required) when using join_windomain option."
285285
default = null
286286
}
287287

@@ -296,28 +296,28 @@ variable "windomain" {
296296
}
297297

298298
variable "domain_admin_user" {
299-
description = "Domain admin user to join the server to AD.(Required) when using join_windomain option"
299+
description = "Domain admin user to join the server to AD.(Required) when using join_windomain option."
300300
default = null
301301
}
302302

303303
variable "domain_admin_password" {
304-
description = "Doamin User pssword to join the server to AD.(Required) when using join_windomain option"
304+
description = "Doamin User pssword to join the server to AD.(Required) when using join_windomain option."
305305
default = null
306306
}
307307

308308
variable "orgname" {
309-
description = "Organization name for when joining windows server to AD"
309+
description = "Organization name for when joining windows server to AD."
310310
default = null
311311
}
312312

313313
variable "auto_logon" {
314-
description = " Specifies whether or not the VM automatically logs on as Administrator. Default: false"
314+
description = " Specifies whether or not the VM automatically logs on as Administrator. Default: false."
315315
type = bool
316316
default = null
317317
}
318318

319319
variable "auto_logon_count" {
320-
description = "Specifies how many times the VM should auto-logon the Administrator account when auto_logon is true. This should be set accordingly to ensure that all of your commands that run in run_once_command_list can log in to run"
320+
description = "Specifies how many times the VM should auto-logon the Administrator account when auto_logon is true. This should be set accordingly to ensure that all of your commands that run in run_once_command_list can log in to run."
321321
default = null
322322
}
323323

@@ -327,7 +327,7 @@ variable "time_zone" {
327327
}
328328

329329
variable "run_once" {
330-
description = "List of Comamnd to run during first logon (Automatic login set to 1)"
330+
description = "List of Comamnd to run during first logon (Automatic login set to 1)."
331331
type = list(string)
332332
default = null
333333
}
@@ -338,7 +338,7 @@ variable "productkey" {
338338
}
339339

340340
variable "full_name" {
341-
description = "The full name of the user of this virtual machine. This populates the user field in the general Windows system information. Default - Administrator"
341+
description = "The full name of the user of this virtual machine. This populates the user field in the general Windows system information. Default - Administrator."
342342
default = null
343343
}
344344

@@ -360,14 +360,80 @@ variable "wait_for_guest_net_timeout" {
360360
default = 5
361361
}
362362

363+
variable "ignored_guest_ips" {
364+
description = "List of IP addresses and CIDR networks to ignore while waiting for an available IP address using either of the waiters. Any IP addresses in this list will be ignored if they show up so that the waiter will continue to wait for a real IP address."
365+
type = list(string)
366+
default = []
367+
}
368+
363369
variable "vm_depends_on" {
364-
description = "Add any external depend on module here like vm_depends_on = [module.fw_core01.firewall]"
370+
description = "Add any external depend on module here like vm_depends_on = [module.fw_core01.firewall]."
365371
type = any
366372
default = null
367373
}
368374

369375
variable "tag_depends_on" {
370-
description = "Add any external depend on module here like tag_depends_on = [vsphere_tag.foo.id]"
376+
description = "Add any external depend on module here like tag_depends_on = [vsphere_tag.foo.id]."
371377
type = any
372378
default = null
373379
}
380+
381+
variable "hv_mode" {
382+
description = "The (non-nested) hardware virtualization setting for this virtual machine. Can be one of hvAuto, hvOn, or hvOff."
383+
type = string
384+
default = null
385+
}
386+
387+
variable "ept_rvi_mode" {
388+
description = "The EPT/RVI (hardware memory virtualization) setting for this virtual machine."
389+
type = string
390+
default = null
391+
}
392+
393+
variable "nested_hv_enabled" {
394+
description = "Enable nested hardware virtualization on this virtual machine, facilitating nested virtualization in the guest."
395+
type = bool
396+
default = null
397+
}
398+
399+
variable "enable_logging" {
400+
description = "Enable logging of virtual machine events to a log file stored in the virtual machine directory."
401+
type = bool
402+
default = null
403+
}
404+
405+
variable "cpu_performance_counters_enabled" {
406+
description = "Enable CPU performance counters on this virtual machine."
407+
type = bool
408+
default = null
409+
}
410+
411+
variable "swap_placement_policy" {
412+
description = "The swap file placement policy for this virtual machine. Can be one of inherit, hostLocal, or vmDirectory."
413+
type = string
414+
default = null
415+
}
416+
417+
variable "latency_sensitivity" {
418+
description = "Controls the scheduling delay of the virtual machine. Use a higher sensitivity for applications that require lower latency, such as VOIP, media player applications, or applications that require frequent access to mouse or keyboard devices.Can be one of low, normal, medium, or high."
419+
type = string
420+
default = null
421+
}
422+
423+
variable "shutdown_wait_timeout" {
424+
description = "The amount of time, in minutes, to wait for a graceful guest shutdown when making necessary updates to the virtual machine. If force_power_off is set to true, the VM will be force powered-off after this timeout, otherwise an error is returned."
425+
type = string
426+
default = null
427+
}
428+
429+
variable "migrate_wait_timeout" {
430+
description = "The amount of time, in minutes, to wait for a graceful guest shutdown when making necessary updates to the virtual machine. If force_power_off is set to true, the VM will be force powered-off after this timeout, otherwise an error is returned."
431+
type = string
432+
default = null
433+
}
434+
435+
variable "force_power_off" {
436+
description = "If a guest shutdown failed or timed out while updating or destroying (see shutdown_wait_timeout), force the power-off of the virtual machine."
437+
type = bool
438+
default = null
439+
}

0 commit comments

Comments
 (0)