Terraform.VirtualMachines/terraform/SRV01.tf
djpbessems e56b23c414
Some checks failed
continuous-integration/drone/push Build is failing
Disable deployment components partially
2022-03-03 10:34:17 +01:00

73 lines
2.4 KiB
HCL

data "vsphere_ovf_vm_template" "ovf-srv" {
name = "ovf-srv"
resource_pool_id = data.vsphere_resource_pool.pool.id
datastore_id = data.vsphere_datastore.datastore.id
host_system_id = data.vsphere_host.host.id
remote_ovf_url = "https://${var.repo_username}:${var.repo_password}@sn.itch.fyi/Repository/rel/Windows-Server-2019-LTSC.ova"
deployment_option = "standalone-small"
disk_provisioning = "thin"
}
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_ovf_vm_template.ovf-srv.resource_pool_id
datastore_id = data.vsphere_ovf_vm_template.ovf-srv.datastore_id
host_system_id = data.vsphere_ovf_vm_template.ovf-srv.host_system_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
}
ovf_deploy {
remote_ovf_url = data.vsphere_ovf_vm_template.ovf-srv.remote_ovf_url
deployment_option = data.vsphere_ovf_vm_template.ovf-srv.deployment_option
}
vapp {
properties = {
"guestinfo.hostname" = "TF-SRV01"
"guestinfo.ipaddress" = "10.0.0.42"
"guestinfo.prefixlength" = "24"
"guestinfo.dnsserver" = "10.0.0.21"
"guestinfo.gateway" = "10.0.0.1"
"guestinfo.administratorpw" = var.adds_password
"guestinfo.ntpserver" = "0.pool.ntp.org,1.pool.ntp.org,2.pool.ntp.org"
}
}
// "addsconfig.domainname" = var.adds_domainname
// "addsconfig.username" = var.adds_username
// "addsconfig.password" = var.adds_password
// depends_on = [
// vsphere_virtual_machine.vm-dc
// ]
// # This does not actually achieve protection from destruction, see https://github.com/hashicorp/terraform/issues/17599
// lifecycle {
// prevent_destroy = true
// }
}