Windows自定义不适用于terraform

时间:2018-12-18 04:14:20

标签: powershell terraform winrm

我正在尝试使用terraform创建和自定义具有Windows VM的基础结构。提供程序是 VMWare vSphere 。 VM创建正确完成,但客户端计算机内部的自定义未完成。我的配置如下:

resource "vsphere_virtual_machine" "vm" {
  count            = "2"
  name             = "${var.virtual_machine_name_prefix}${count.index}"
  resource_pool_id = "${data.vsphere_resource_pool.resource_pool.id}"
  host_system_id   = "${data.vsphere_host.host.*.id[count.index]}"
  datastore_id     = "${data.vsphere_datastore.datastore.id}"
    folder         = "my-vm-folder"
  num_cpus = 8
  memory   = 8192
  guest_id = "${data.vsphere_virtual_machine.template.guest_id}"

    scsi_type = "${data.vsphere_virtual_machine.template.scsi_type}"

  network_interface {
        # label             = "${data.vsphere_network.network.name}"
    network_id   = "${data.vsphere_network.network.id}"
    adapter_type = "${data.vsphere_virtual_machine.template.network_interface_types[0]}"
  }

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

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

    customize {
      windows_options {
        computer_name = "${var.virtual_machine_name_prefix}${count.index}"
        full_name     = "${var.virtual_machine_name_prefix}${count.index}"
        organization_name = "myorg"
        join_domain = "mydomain.com"
        domain_admin_user = "admin"
        domain_admin_password = "P@ssword"
      }

            network_interface {
        dns_server_list = ["${var.virtual_machine_dns_servers}"]
      }    
    }
  }
}

每当我尝试创建时,我收到的错误消息是:

* vsphere_virtual_machine.vm[1]: 1 error(s) occurred:

* vsphere_virtual_machine.vm.1:
Virtual machine customization failed on "/foldername/vm-name-1":

timeout waiting for customization to complete

The virtual machine has not been deleted to assist with troubleshooting. If
corrective steps are taken without modifying the "customize" block of the
resource configuration, the resource will need to be tainted before trying
again. For more information on how to do this, see the following page:
https://www.terraform.io/docs/commands/taint.html

看来terraform无法与客户端VM通信导致超时。我需要提供其他什么来使Terraform投入使用吗?

1 个答案:

答案 0 :(得分:0)

如果自定义失败时 VM 屏幕上显示“Windows 安装程序无法将 Windows 配置为在此计算机的硬件上运行”,则可能是 sysprep 有问题。