重新配置虚拟机时出错:处理磁盘更改时出错 post-clone: disk.0: ServerFaultCode:

error reconfiguring virtual machine: error processing disk changes post-clone: disk.0: ServerFaultCode:

我想通过 terraform 从快照创建 Vsphere VM。我遇到了这样的问题。

错误重新配置虚拟机:错误处理磁盘更改post-clone:disk.0:ServerFaultCode:NoPermission:RESOURCE (vm-1439:2000), ACTION (queryAssociatedProfile):RESOURCE (vm-1439), 行动 (PolicyIDByVirtualDisk)

这是我的代码

data "vsphere_datacenter" "dc" {
  name = var.vm_datacenter
}

data "vsphere_datastore" "datastore" {
  name          = var.vm_datastore
  datacenter_id = data.vsphere_datacenter.dc.id
}

data "vsphere_compute_cluster" "cluster" {
  name          = "${var.vsphere_cluster}"
  datacenter_id = "${data.vsphere_datacenter.dc.id}"
}


data "vsphere_network" "network" {
  name          = var.vm_network
  datacenter_id = data.vsphere_datacenter.dc.id
}

data "vsphere_virtual_machine" "template" {
  name          = "${var.vm_template}"
  datacenter_id = "${data.vsphere_datacenter.dc.id}"
}

resource "vsphere_virtual_machine" "vm" {
  name             = var.vm_name
  resource_pool_id = data.vsphere_compute_cluster.cluster.resource_pool_id
  datastore_id     = data.vsphere_datastore.datastore.id


  guest_id = "centos7_64Guest"
  folder = var.vm_folder

    network_interface {
    network_id = data.vsphere_network.network.id
    adapter_type = "vmxnet3"
  }

  disk {
    label            = "disk0"
    size             = "${data.vsphere_virtual_machine.template.disks.0.size}"
    eagerly_scrub    = "${data.vsphere_virtual_machine.template.disks.0.eagerly_scrub}"
    thin_provisioned = "${data.vsphere_virtual_machine.template.disks.0.thin_provisioned}"
  }


  clone {
  template_uuid = "${data.vsphere_virtual_machine.template.id}"
  linked_clone = false

  customize {
    timeout = "20"

    linux_options {
      host_name = "localhost.localdomain"
      domain    = "${var.vm_domain}"
    }

    network_interface {
      ipv4_address = "${var.vm_ip}"
      ipv4_netmask = "${var.vm_netmask}"
    }

    ipv4_gateway    = "${var.vm_gateway}"
    dns_server_list = ["${var.vm_dns}"]
  }
  } 
}

如果你有什么想法,请告诉我。 非常感谢。

将用户添加到顶级 vcenter 对象(非传播)并在角色权限(用户所属)中添加配置文件驱动存储 -> 配置文件驱动存储视图。

因此要么将 terraform vsphere 提供程序降级到版本 1.15.0。

来源:https://github.com/hashicorp/terraform-provider-vsphere/issues/974#issuecomment-591956362