Terraform.VirtualMachines/terraform/main.tf

48 lines
1.2 KiB
Terraform
Raw Normal View History

2021-02-02 12:06:52 +00:00
terraform {
backend "pg" {}
2021-02-02 12:30:06 +00:00
required_providers {
vsphere = {
source = "hashicorp/vsphere"
2022-03-03 12:37:36 +00:00
version = "2.1.0"
2021-02-02 12:30:06 +00:00
}
}
2021-02-02 12:06:52 +00:00
}
provider "vsphere" {
2021-03-31 07:27:34 +00:00
vsphere_server = var.hv_fqdn
user = var.hv_username
password = var.hv_password
2021-02-02 12:06:52 +00:00
allow_unverified_ssl = true
}
data "vsphere_datacenter" "dc" {
2021-03-31 07:27:34 +00:00
name = var.hv_datacenter
2021-02-02 12:06:52 +00:00
}
data "vsphere_resource_pool" "pool" {
2022-03-03 09:50:59 +00:00
name = var.hv_resourcepool
// name = "/${var.hv_datacenter}/host/${var.hv_host}/Resources"
2021-02-02 12:06:52 +00:00
datacenter_id = data.vsphere_datacenter.dc.id
}
2021-03-31 07:27:34 +00:00
data "vsphere_host" "host" {
name = var.hv_host
2021-03-31 07:47:41 +00:00
datacenter_id = data.vsphere_datacenter.dc.id
2021-02-02 12:06:52 +00:00
}
2021-03-31 07:27:34 +00:00
data "vsphere_datastore" "datastore" {
name = var.hv_datastore
2021-02-02 12:06:52 +00:00
datacenter_id = data.vsphere_datacenter.dc.id
}
data "vsphere_network" "network" {
2021-03-31 07:27:34 +00:00
name = var.hv_network
2021-02-02 12:06:52 +00:00
datacenter_id = data.vsphere_datacenter.dc.id
2022-03-03 12:37:36 +00:00
}
data "vsphere_virtual_machine" "template" {
name = var.vm_template
datacenter_id = data.vsphere_datacenter.dc.id
2021-02-02 12:06:52 +00:00
}