Error building windows on customize step

Hi all,

Trying to build a template using vsphere-clone and the customize section to get an IP to the vm so it can be updated to latest, but it always fails at the customize step. Is there a way to get more information on the error itself? I’ve checked everywhere but I don’t see many/any examples using vsphere-clone. No specific errors show using PACKER_LOG=1 either, output of command clipped below the customize json. I’ve tried using a bare sysprep.xml file also but same error. Any hints on where to look would be greatly appreciated, or if this is even possible using vsphere-clone builder.

  "customize": {
    "dns_server_list": [
      "xx.xx.xx.xx",
      "xx.xx.xx.xx"
    ],
    "ipv4_gateway": "xx.xx.xx.1",
    "network_interface": {
      "ipv4_address": "xx.xx.xx.74",
      "ipv4_netmask": "23"
    },
    "windows_sysprep_file": "sysprep.xml"
  },

2021/11/22 15:55:38 Build debug mode: true
2021/11/22 15:55:38 Force build: false
2021/11/22 15:55:38 On error: ask
2021/11/22 15:55:38 Debug enabled, so waiting for build to finish: Windows2019
2021/11/22 15:55:38 Starting build run: Windows2019
2021/11/22 15:55:38 Running builder: vsphere-clone
2021/11/22 15:55:38 [INFO] (telemetry) Starting builder Windows2019
==> Windows2019: Pausing after run of step ‘StepConnect’. Press enter to continue.
2021/11/22 15:55:40 packer-builder-vsphere-clone plugin: No CD files specified. CD disk will not be made.
==> Windows2019: Pausing after run of step ‘StepCreateCD’. Press enter to continue.
==> Windows2019: Pausing after run of step ‘StepRemoteUpload’. Press enter to continue.
==> Windows2019: Cloning VM…
==> Windows2019: Pausing after run of step ‘StepCloneVM’. Press enter to continue. ==> Windows2019: Customizing hardware…
==> Windows2019: Pausing after run of step ‘StepConfigureHardware’. Press enter to continue.
==> Windows2019: Mounting ISO images…
==> Windows2019: Pausing after run of step ‘StepAddCDRom’. Press enter to continue.
==> Windows2019: Adding configuration parameters…
==> Windows2019: Pausing after run of step ‘StepConfigParams’. Press enter to continue.
==> Windows2019: Customizing VM…
==> Windows2019: Cannot complete customization.
==> Windows2019: Step “StepCustomize” failed
==> Windows2019: [c] Clean up and exit, [a] abort without cleanup, or [r] retry step (build may fail even if retry succeeds)? a
==> Windows2019: Cannot complete customization.
==> Windows2019: Step “StepCustomize” failed, aborting…
==> Windows2019: Pausing before cleanup of step ‘StepConfigParams’. Press enter to continue.
==> Windows2019: aborted: skipping cleanup of step "StepConfigParams"
==> Windows2019: Pausing before cleanup of step ‘StepAddCDRom’. Press enter to continue.
==> Windows2019: aborted: skipping cleanup of step "StepAddCDRom"
==> Windows2019: Pausing before cleanup of step ‘StepConfigureHardware’. Press enter to continue.
==> Windows2019: aborted: skipping cleanup of step "StepConfigureHardware"
==> Windows2019: Pausing before cleanup of step ‘StepCloneVM’. Press enter to continue.
==> Windows2019: aborted: skipping cleanup of step "StepCloneVM"
==> Windows2019: Pausing before cleanup of step ‘StepRemoteUpload’. Press enter to continue.
==> Windows2019: aborted: skipping cleanup of step "StepRemoteUpload"
==> Windows2019: Pausing before cleanup of step ‘StepCreateCD’. Press enter to continue.
==> Windows2019: aborted: skipping cleanup of step "StepCreateCD"
==> Windows2019: Pausing before cleanup of step ‘StepConnect’. Press enter to continue.
==> Windows2019: aborted: skipping cleanup of step "StepConnect"
Build ‘Windows2019’ errored after 21 seconds 21 milliseconds: Cannot complete customization.
2021/11/22 15:55:59 [INFO] (telemetry) ending Windows2019
2021/11/22 15:55:59 Waiting on builds to complete…
==> Wait completed after 21 seconds 21 milliseconds
2021/11/22 15:55:59 machine readable: error-count string{“1”}
==> Some builds didn’t complete successfully and had errors:
2021/11/22 15:55:59 machine readable: Windows2019,error string{“Cannot complete customization.”}
==> Builds finished but no artifacts were created.
2021/11/22 15:55:59 [INFO] (telemetry) Finalizing.
==> Wait completed after 21 seconds 21 milliseconds
==> Some builds didn’t complete successfully and had errors:
→ Windows2019: Cannot complete customization.
==> Builds finished but no artifacts were created.

Where you able to find a solution? I am having the same issue.

Hi @cshaw1313 & @aardis1
I also had the same issue and I was very perplex as details for vsphere-clone and windows_sysprep_file param are not clear.
And of course nobody in the world is using it except us :roll_eyes:
But fortunately I could make it work.
I found this VMware KB which help me to solve this: VMware Knowledge Base

So I added these lines to my autounattend.xml file:

<?xml version="1.0" encoding="utf-8"?>

<unattend xmlns="urn:schemas-microsoft-com:unattend">

    <settings pass="oobeSystem">

        <component name="Microsoft-Windows-International-Core" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

            <SystemLocale>en-US</SystemLocale>

        </component>

        <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

            <OOBE>

                <HideEULAPage>true</HideEULAPage>

                <HideLocalAccountScreen>true</HideLocalAccountScreen>

                <HideOEMRegistrationScreen>true</HideOEMRegistrationScreen>

                <HideOnlineAccountScreens>true</HideOnlineAccountScreens>

                <HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>

                <NetworkLocation>Work</NetworkLocation>

                <ProtectYourPC>3</ProtectYourPC>

            </OOBE>

            <TimeZone>W. Europe Standard Time</TimeZone>

            <UserAccounts>

                <LocalAccounts>

                    <LocalAccount wcm:action="add">

                        <Name>packer</Name>

                        <Password>

                            <Value>StrongP@ss1234!</Value>

                            <PlainText>true</PlainText>

                        </Password>

                        <Group>Administrators</Group>

                    </LocalAccount>

                </LocalAccounts>

            </UserAccounts>

            <AutoLogon>

                <Enabled>true</Enabled>

                <Username>packer</Username>

                <Password>

                    <Value>StrongP@ss1234!</Value>

                    <PlainText>true</PlainText>

                </Password>

                <LogonCount>1</LogonCount>

            </AutoLogon>

            <FirstLogonCommands>

                <SynchronousCommand wcm:action="add">

                    <Order>1</Order>

                    <!-- Enable WinRM service -->

                    <CommandLine>powershell -ExecutionPolicy Bypass -File C:\Scripts\ConfigureRemotingForAnsible.ps1 -SkipNetworkProfileCheck -ForceNewSSLCert</CommandLine>

                    <RequiresUserInput>true</RequiresUserInput>

                </SynchronousCommand>

            </FirstLogonCommands>

        </component>

        <component name="Microsoft-Windows-Deployment" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

            <RunSynchronous>

                <RunSynchronousCommand wcm:action="add">

                    <Path>C:\sysprep\guestcustutil.exe restoreMountedDevices</Path>

                    <Order>1</Order>

                </RunSynchronousCommand>

                <RunSynchronousCommand wcm:action="add">

                    <Path>C:\sysprep\guestcustutil.exe flagComplete</Path>

                    <Order>2</Order>

                </RunSynchronousCommand>

                <RunSynchronousCommand wcm:action="add">

                    <Path>C:\sysprep\guestcustutil.exe deleteContainingFolder</Path>

                    <Order>3</Order>

                </RunSynchronousCommand>

            </RunSynchronous>

        </component>

    </settings>

</unattend>

And so to use it with windows_sysprep_file, no need to add floppy or cd-rom (that was what I first tried), just reference the file:

customize {

    network_interface {

           ipv4_address = null

         }

    windows_sysprep_file = "${path.root}/autounattend.xml"

  }