Hi Team ,
I have a work flow as follows :
- Create a datacenter
- Create Clusters under datacenter created in Step 1
- For each cluster add N hosts , which are not already part of datacenter or cluster.
resource.tf
resource "vsphere_datacenter" "uwsim_datacenter" {
description = "Create a Datacenter"
name = var.datacenter_name
}
# Get Handle to datacenter Created above
data "vsphere_datacenter" "datacenter" {
name = var.datacenter_name
depends_on=[vsphere_datacenter.uwsim_datacenter]
}
#Add Clusters mentioned in terraform.tfvars
resource "vsphere_compute_cluster" "compute_cluster" {
count = length(var.cluster_names)
name = var.cluster_names[count.index]
datacenter_id = "${data.vsphere_datacenter.datacenter.id}"
}
#Add Host to each cluster need some help on it
terraform.tfvars
vsphere_username="some user"
vsphere_password="some password"
vsphere_server="some server"
datacenter_name="UWSIMs"
cluster_names=[ "Uwsim01","Uwsim02","Uwsim03"]
hosts={
Uwsim01=[ "173.173.9.1", "173.173.9.10", "173.173.9.11" ],
Uwsim02=[ "173.173.9.100", "173.173.9.101", "173.173.9.102" ]
...
]
variables.tf
variable "vsphere_username" {}
variable "vsphere_password" {}
variable "vsphere_server" {}
variable "datacenter_name" {}
variable "cluster_names" {
type = list(string)
}
variable "hosts" {
type = map(list(string))
}
Kindly Help