This commit is contained in:
parent
8e67d24e08
commit
84832dd3a6
40
terraform/SRV01_template.tf
Normal file
40
terraform/SRV01_template.tf
Normal file
@ -0,0 +1,40 @@
|
||||
resource "vsphere_virtual_machine" "vm-srv" {
|
||||
name = "TF-SRV01"
|
||||
|
||||
num_cpus = var.vm_numcpu
|
||||
memory = var.vm_memory
|
||||
|
||||
datacenter_id = data.vsphere_datacenter.dc.id
|
||||
folder = var.hv_vmfolder
|
||||
|
||||
// guest_id = data.vsphere_ovf_vm_template.ovf-srv.guest_id
|
||||
resource_pool_id = data.vsphere_resource_pool.pool.id
|
||||
datastore_id = data.vsphere_datastore.datastore.id
|
||||
host_system_id = data.vsphere_host.host.id
|
||||
|
||||
network_interface {
|
||||
network_id = data.vsphere_network.network.id
|
||||
}
|
||||
wait_for_guest_net_timeout = 15
|
||||
|
||||
disk {
|
||||
label = "disk0"
|
||||
unit_number = 0
|
||||
size = 40
|
||||
thin_provisioned = true
|
||||
}
|
||||
disk {
|
||||
label = "disk1"
|
||||
unit_number = 1
|
||||
size = 25
|
||||
thin_provisioned = true
|
||||
}
|
||||
|
||||
clone {
|
||||
template_uuid = data.vsphere_virtual_machine.template.id
|
||||
}
|
||||
// # This does not actually achieve protection from destruction, see https://github.com/hashicorp/terraform/issues/17599
|
||||
// lifecycle {
|
||||
// prevent_destroy = true
|
||||
// }
|
||||
}
|
@ -4,7 +4,7 @@ terraform {
|
||||
required_providers {
|
||||
vsphere = {
|
||||
source = "hashicorp/vsphere"
|
||||
version = "~> 1.25.0"
|
||||
version = "2.1.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -40,4 +40,9 @@ data "vsphere_datastore" "datastore" {
|
||||
data "vsphere_network" "network" {
|
||||
name = var.hv_network
|
||||
datacenter_id = data.vsphere_datacenter.dc.id
|
||||
}
|
||||
|
||||
data "vsphere_virtual_machine" "template" {
|
||||
name = var.vm_template
|
||||
datacenter_id = data.vsphere_datacenter.dc.id
|
||||
}
|
@ -14,6 +14,7 @@ variable "hv_network" {}
|
||||
variable "repo_username" {}
|
||||
variable "repo_password" {}
|
||||
|
||||
variable "vm_template" {}
|
||||
variable "vm_numcpu" {}
|
||||
variable "vm_memory" {}
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
vm_template = "Windows-Server-2019-LTSC"
|
||||
vm_numcpu = 2
|
||||
vm_memory = 4096
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user