我有一个Terraform文件可以在我的家庭vSphere实例上创建资源池。 Terraform文件如下所示:
provider "vsphere" {
vsphere_server = "${var.vsphere_server}"
user = "${var.vsphere_user}"
password = "${var.vsphere_password}"
allow_unverified_ssl = true
}
data "vsphere_datacenter" "dc" {
name = "Datacenter1"
}
data "vsphere_compute_cluster" "compute_cluster" {
name = "Cluster1"
datacenter_id = "${data.vsphere_datacenter.dc.id}"
}
resource "vsphere_resource_pool" "resource_pool" {
name = "terraform-resource-pool-test"
parent_resource_pool_id = "${data.vsphere_compute_cluster.compute_cluster.resource_pool_id}"
}
terraform计划的输出如下:
# vsphere_resource_pool.resource_pool will be created
+ resource "vsphere_resource_pool" "resource_pool" {
+ cpu_expandable = true
+ cpu_limit = -1
+ cpu_reservation = 0
+ cpu_share_level = "normal"
+ cpu_shares = (known after apply)
+ id = (known after apply)
+ memory_expandable = true
+ memory_limit = -1
+ memory_reservation = 0
+ memory_share_level = "normal"
+ memory_shares = (known after apply)
+ name = "terraform-resource-pool-test"
+ parent_resource_pool_id = "resgroup-8"
}
Plan: 1 to add, 0 to change, 0 to destroy.
但是我总是得到以下错误:
vsphere_resource_pool.resource_pool:正在创建...
错误:ServerFaultCode:该对象不支持该操作。
在main.tf第34行的资源“ vsphere_resource_pool”中 “ resource_pool”:34:资源“ vsphere_resource_pool” “ resource_pool” {
关于如何解决此问题的任何想法?我正在使用vSphere Version 6.0.0 Build 3617395
答案 0 :(得分:0)
代码看起来不错。
某些手动修复将对此情况有所帮助。
# clean below folder and files from current directory, where you run `terraform apply`
rm -rf .terraform
rm terraform.tfstate* in any subfolders
# clean below folder from home directory.
rm ~/.terraform.d/
terraform init
terraform plan
terraform apply