Rebase to vSphere template
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Danny Bessems 2022-03-03 13:37:36 +01:00
parent 8e67d24e08
commit 84832dd3a6
5 changed files with 48 additions and 1 deletions

View 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
// }
}

View File

@ -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
}

View File

@ -14,6 +14,7 @@ variable "hv_network" {}
variable "repo_username" {}
variable "repo_password" {}
variable "vm_template" {}
variable "vm_numcpu" {}
variable "vm_memory" {}

View File

@ -1,3 +1,4 @@
vm_template = "Windows-Server-2019-LTSC"
vm_numcpu = 2
vm_memory = 4096