我正在尝试使用Packer(vmware-iso生成器)和vSphere自动生成Windows Server 2016“黄金映像”。 VM创建成功,autounattend.xml成功运行,并且VM运行所有首次重新启动活动。此后,VM /打包程序将坐在“等待WinRM可用...”,直到超时。
注意:我们仅使用静态IP。没有DHCP。
Packer => 1.3.4
vSphere => 6.5
vmware-iso生成器=>最新
我确保:
esxcli system settings advanced set -o /Net/GuestIPHack -i 1
{
"variables": {
"name": "",
"vm_name": "",
"guest_os_type": "",
"tools_upload_flavor": "",
"headless": "false",
"iso_url": "",
"iso_checksum": "",
"iso_checksum_type": "",
"disk_size": "60000",
"admin_user": "",
"admin_password": "",
"memsize": "4096",
"numvcpus": "2",
"network_name": "",
"vsphere_server": "",
"vsphere_user": "",
"vsphere_pass": "",
"vsphere_datastore": ""
},
"builders": [
{
"name": "{{user `name`}}",
"vm_name": "{{user `vm_name`}}",
"keep_registered": false,
"ovftool_options": [
"--noSSLVerify"
],
"type": "vmware-iso",
"guest_os_type": "{{user `guest_os_type`}}",
"tools_upload_flavor": "{{user `tools_upload_flavor`}}",
"headless": "{{user `headless`}}",
"boot_wait": "1m",
"iso_url": "{{user `iso_url`}}",
"iso_checksum": "{{user `iso_checksum`}}",
"iso_checksum_type": "{{user `iso_checksum_type`}}",
"disk_size": "{{user `disk_size`}}",
"floppy_files": [
"./2016/resources/autounattend.xml",
"./2016/resources/feature-reset.ps1",
"./2016/resources/postinstall.xml",
"./common/configure-winrm.ps1",
"./common/configure-ip.ps1",
"./common/configure-domain.ps1",
"./common/install-vmware-tools.ps1"
],
"vnc_disable_password": true,
"communicator": "winrm",
"winrm_insecure": true,
"winrm_username": "{{user `admin_user`}}",
"winrm_password": "{{user `admin_password`}}",
"winrm_timeout": "6h",
"shutdown_command": "C:/windows/system32/sysprep/sysprep.exe /generalize /oobe /unattend:A:/postinstall.xml /quiet /shutdown",
"remote_type": "esx5",
"remote_host": "{{user `vsphere_server`}}",
"remote_password": "{{user `vsphere_pass`}}",
"remote_username": "{{user `vsphere_user`}}",
"remote_datastore": "{{user `vsphere_datastore`}}",
"skip_compaction": false,
"network_adapter_type": "VMXNET3",
"vmx_data": {
"gui.fitguestusingnativedisplayresolution": false,
"memsize": "{{user `memsize`}}",
"numvcpus": "{{user `numvcpus`}}",
"virtualhw.productcompatibility": "esx",
"virtualHW.version": 10,
"scsi0.virtualDev": "lsisas1068",
"ethernet0.networkName": "{{user `network_name`}}"
},
"vmx_data_post": {
"ide0:0.startConnected": false,
"ide0:1.startConnected": false,
"ide1:0.startConnected": false,
"ide1:1.startConnected": false,
"ide0:0.deviceType": "cdrom-raw",
"ide0:1.deviceType": "cdrom-raw",
"ide1:0.deviceType": "cdrom-raw",
"ide1:1.deviceType": "cdrom-raw",
"ide0:0.clientDevice": true,
"ide0:1.clientDevice": true,
"ide1:0.clientDevice": true,
"ide1:1.clientDevice": true,
"ide0:0.present": false,
"ide0:1.present": false,
"ide1:0.present": true,
"ide1:1.present": false,
"ide0:0.fileName": "emptyBackingString",
"ide0:1.fileName": "emptyBackingString",
"ide1:0.fileName": "emptyBackingString",
"ide1:1.fileName": "emptyBackingString"
}
}
]
}
==> win-server-2016-template: Retrieving ISO
win-server-2016-template: Found already downloaded, initial checksum matched, no download needed: https://software-download.microsoft.com/download/pr/Windows_Server_2016_Datacenter_EVAL_en-us_14393_refresh.ISO
==> win-server-2016-template: Creating floppy disk...
win-server-2016-template: Copying files flatly from floppy_files
win-server-2016-template: Copying file: ./2016/resources/autounattend.xml
win-server-2016-template: Copying file: ./2016/resources/feature-reset.ps1
win-server-2016-template: Copying file: ./2016/resources/postinstall.xml
win-server-2016-template: Copying file: ./common/configure-winrm.ps1
win-server-2016-template: Copying file: ./common/configure-ip.ps1
win-server-2016-template: Copying file: ./common/configure-domain.ps1
win-server-2016-template: Copying file: ./common/install-vmware-tools.ps1
win-server-2016-template: Done copying files from floppy_files
win-server-2016-template: Collecting paths from floppy_dirs
win-server-2016-template: Resulting paths from floppy_dirs : []
win-server-2016-template: Done copying paths from floppy_dirs
==> win-server-2016-template: Uploading Floppy to remote machine...
==> win-server-2016-template: Remote cache was verified skipping remote upload...
==> win-server-2016-template: Creating required virtual machine disks
==> win-server-2016-template: Building and writing VMX file
==> win-server-2016-template: Registering remote VM...
==> win-server-2016-template: Starting virtual machine...
==> win-server-2016-template: Waiting 1m0s for boot...
==> win-server-2016-template: Connecting to VM via VNC (esxihost.domain.com:5900)
==> win-server-2016-template: Typing the boot command over VNC...
==> win-server-2016-template: Waiting for WinRM to become available...
2019/02/12 00:45:50 packer.exe: 2019/02/12 00:45:50 [DEBUG] Opening new ssh session
2019/02/12 00:45:50 packer.exe: 2019/02/12 00:45:50 [DEBUG] starting remote command: esxcli --formatter csv network vm list
2019/02/12 00:45:51 packer.exe: 2019/02/12 00:45:51 [DEBUG] Error getting WinRM host: EOF
2019/02/12 00:45:56 packer.exe: 2019/02/12 00:45:56 [DEBUG] Opening new ssh session
2019/02/12 00:45:56 packer.exe: 2019/02/12 00:45:56 [DEBUG] starting remote command: esxcli --formatter csv network vm list
2019/02/12 00:45:56 packer.exe: 2019/02/12 00:45:56 [DEBUG] Error getting WinRM host: EOF
2019/02/12 00:46:01 packer.exe: 2019/02/12 00:46:01 [DEBUG] Opening new ssh session
2019/02/12 00:46:01 packer.exe: 2019/02/12 00:46:01 [DEBUG] starting remote command: esxcli --formatter csv network vm list
2019/02/12 00:46:02 packer.exe: 2019/02/12 00:46:02 [DEBUG] Error getting WinRM host: EOF
这似乎是打包程序无法从ESXi主机(Error getting WinRM host: EOF
)获取IP地址的问题。