Reputation: 481
I'm pretty much a noob with terraform and the vsphere provider, and I'm bumping up into all the noob problems.
We're hoping to land a VM on a managed standalone (not clustered) ESXi 65 host connected to vsphere, but I can't get the resource_pool resource statement correct and, as shown, I got a little desperate and tried all permutations I could think of:
provider "vsphere" {
vsphere_server = "vcs1.fq.dn"
alias = "prod"
allow_unverified_ssl = true
}
data "vsphere_datacenter" "prod" {
provider = vsphere.prod
name = "PROD Datacenter"
}
data "vsphere_resource_pool" "vmhost23" {
provider = vsphere.prod
datacenter_id = data.vsphere_datacenter.prod.id
# name = "vmhost23/Resources"
# name = "vmhost23/resources"
# name = "vmhost23/"
# name = "/"
name = "/Resources"
# name = "/resources"
# name = "vmhost23/Resources/"
# name = "vmhost23/resources/"
# name = "vmhost23/"
# name = "/"
# name = "/Resources/"
# name = "/resources/"
# name = "vmhost23.fq.dn"
# name = "vmhost23.fq.dn/"
# name = "vmhost23.fq.dn/Resources/"
# name = "vmhost23.fq.dn/Resources"
# name = "vmhost23.fq.dn/resources/"
# name = "vmhost23.fq.dn/resources"
}
unfortunately, there's just no joy:
data.vsphere_datacenter.prod: Refreshing state...
data.vsphere_datastore.vmhost23: Refreshing state...
data.vsphere_resource_pool.vmhost23: Refreshing state...
data.vsphere_network.DMZ-prod: Refreshing state...
data.vsphere_datacenter.dc: Refreshing state...
data.vsphere_datastore.datastore: Refreshing state...
data.vsphere_compute_cluster.cluster: Refreshing state...
data.vsphere_datastore_cluster.datastore_cluster: Refreshing state...
data.vsphere_network.TEST-APP: Refreshing state...
data.vsphere_virtual_machine.template: Refreshing state...
:
vsphere_virtual_machine.prdsat: Refreshing state... [id=42190b77-a6a7-8693-e05f-c11528d1afa4]
Error: error fetching resource pool: resource pool '/Resources' not found
on vm-prdsplidx01x.tf line 4, in data "vsphere_resource_pool" "vmhost23":
4: data "vsphere_resource_pool" "vmhost23" {
Upvotes: 0
Views: 3266
Reputation: 1
I enabled DRS/HA on my vCenter7 which helped getting resource_pool. Also using govc will get the path to resource pool ID.
govc about govc find / -type p
terraform import vsphere_resource_pool.resource_pool /dc1/host/compute-cluster1/Resources/ The above gets you the tfstate.
Upvotes: 0
Reputation: 481
I've found the solution.
In my case, the fact that the host is in a folder - yeah, really - makes all the difference. It was such an insignificant data point that I ignored it.
So, in my case, what worked was
data "vsphere_resource_pool" "vmhost23" {
provider = vsphere.prod
name = "FolderName/vmhost23.fq.dn"
datacenter_id = data.vsphere_datacenter.prod.id
}
Capitalization is important, and it seems to need the FQDN on the ESXi hostname; but definitely correct me if you found a way to make it work with short-hostnames or lower-case folder names.
So, another hurdle down and only 31 to go! Thanks for playing Duck for me.
Upvotes: 2