Terraform.VirtualMachines/terraform/DC01.tf
djpbessems 7f01f77008
Some checks failed
continuous-integration/drone/push Build is failing
Rename network;Add new vApp properties w/ vars
2021-03-31 09:59:33 +02:00

71 lines
2.5 KiB
HCL

data "vsphere_ovf_vm_template" "ovf-dc" {
name = "ovf-dc"
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/ADDS-appliance.ova"
deployment_option = "standalone"
}
resource "vsphere_virtual_machine" "vm-dc" {
name = "TF-DC01"
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-dc.guest_id
resource_pool_id = data.vsphere_ovf_vm_template.ovf-dc.resource_pool_id
datastore_id = data.vsphere_ovf_vm_template.ovf-dc.datastore_id
host_system_id = data.vsphere_ovf_vm_template.ovf-dc.host_system_id
network_interface {
network_id = data.vsphere_network.network.id
}
disk {
label = "disk0"
unit_number = 0
size = 40
thin_provisioned = true
}
ovf_deploy {
remote_ovf_url = data.vsphere_ovf_vm_template.ovf-dc.remote_ovf_url
deployment_option = data.vsphere_ovf_vm_template.ovf-dc.deployment_option
}
vapp {
properties = {
"guestinfo.hostname" = "TF-DC01"
"guestinfo.ipaddress" = "10.0.0.21"
"guestinfo.prefixlength" = "24"
"guestinfo.gateway" = "10.0.0.1"
"addsconfig.domainname" = var.adds_domainname
"addsconfig.netbiosname" = var.adds_netbiosname
"addsconfig.administratorpw" = var.adds_password
"addsconfig.safemodepw" = var.adds_password
"addsconfig.ntpserver" = var.adds_ntpserver
"dhcpconfig.startip" = var.dhcp_startip
"dhcpconfig.endip" = var.dhcp_endip
"dhcpconfig.subnetmask" = var.dhcp_subnetmask
"dhcpconfig.gateway" = var.dhcp_gateway
"dhcpconfig.leaseduration" = var.dhcp_leaseduration
"vault.api" = var.vault_api
"vault.token" = var.vault_token
"vault.pwpolicy" = var.vault_pwpolicy
"vault.secret" = var.vault_secret
}
}
# # This does not actually achieve protection from destruction, see https://github.com/hashicorp/terraform/issues/17599
# lifecycle {
# prevent_destroy = true
# }
}