Hello everyone,
I’m encountering an EOF issue with my deployment in Packer, and it’s becoming a persistent problem. I’ve been trying to resolve it for a week but haven’t had any success.
Here is my packer file
packer {
required_version = ">= 1.9.4"
required_plugins {
vsphere = {
source = "github.com/hashicorp/vsphere"
version = ">= 1.2.2"
}
}
}
# ansible = {
# source = "github.com/hashicorp/ansible"
# version = ">= 1.1.0"
source "vsphere-iso" "ws2022" {
// vSphere Settings
vcenter_server = "vcntr-vroot.local"
username = "admin@vsphere.local"
password = var.vcenter_password
datacenter = "LAB1"
cluster = "CLUSTER1"
host = "esxi04-vroot.local"
datastore = "_ESXI04_DS_SSD_RAID1"
folder = "Templates/Test"
insecure_connection = "true"
vm_name = "win2022standard"
CPUs = "2"
cpu_cores = "4"
RAM = "16096"
disk_controller_type = ["pvscsi"]
storage {
disk_size = "327680"
disk_thin_provisioned = true
}
boot_command = [
"<esc><wait><esc><wait><f6><wait><esc><wait>",
"<bs><bs><bs><bs><bs>"
]
network_adapters {
network = "Isolated_STG"
network_card = "vmxnet3"
}
ip_wait_timeout = "3600s"
ip_settle_timeout = "3600s"
iso_paths = [
"[_ESXI04_DS_SSD_RAID1] ISO/SW_DVD9_Win_Server_STD_CORE_2022_2108.34_64Bit_English_DC_STD_MLF_X23-76432.ISO",
"[_ESXI04_DS_SSD_RAID1] ISO/VMware-tools-windows-12.4.0-23259341.iso"
]
communicator = "winrm"
winrm_password = "PASSWORD"
winrm_username = "Administrator"
winrm_insecure = "true"
winrm_timeout = "3m"
winrm_host = "10.1.115.159"
firmware = "bios"
http_directory = "resources"
shutdown_timeout = "2h"
ssh_clear_authorized_keys = true
ssh_username = "root"
cd_files = [
"resources/configs/autounattend.xml",
"resources/scripts/win-update.ps1",
"resources/scripts/install-vmware-tools-from-iso.ps1",
]
}
build {
name = "win2022"
sources = ["source.vsphere-iso.ws2022"]
provisioner "windows-shell" {
inline = ["ipconfig"]
}
provisioner "windows-restart" {
pause_before = "30m"
restart_timeout = "30m"
}
provisioner "powershell" {
scripts = ["resources/scripts/install-vmware-tools-from-iso.ps1"]
}
provisioner "powershell" {
scripts = ["resources/scripts/win-update.ps1"]
}
provisioner "windows-restart" {
restart_timeout = "30m"
}
provisioner "powershell" {
scripts = ["resources/scripts/adjustments.ps1"]
}
provisioner "powershell" {
scripts = ["resources/scripts/cleanup.ps1"]
}
provisioner "windows-restart" {
restart_timeout = "30m"
}
# provisioner "ansible" {
# user = var.build_username
# galaxy_file = "${path.cwd}/ansible/windows-requirements.yml"
# galaxy_force_with_deps = true
# use_proxy = false
# playbook_file = "${path.cwd}/ansible/windows-playbook.yml"
# roles_path = "${path.cwd}/ansible/roles"
# ansible_env_vars = [
# "ANSIBLE_CONFIG=${path.cwd}/ansible/ansible.cfg"
# ]
# extra_arguments = [
# "--extra-vars", "use_proxy=false",
# "--extra-vars", "ansible_connection=winrm",
# "--extra-vars", "ansible_user='${var.build_username}'",
# "--extra-vars", "ansible_password='${var.build_password}'",
# "--extra-vars", "ansible_port='${var.communicator_port}'",
# "--extra-vars", "build_username='${var.build_username}'",
# ]
#}
}
Here is my auto-attended file
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<settings pass="windowsPE">
<component name="Microsoft-Windows-International-Core-WinPE" 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">
<SetupUILanguage>
<UILanguage>en-US</UILanguage>
</SetupUILanguage>
<InputLocale>en-US</InputLocale>
<SystemLocale>en-US</SystemLocale>
<UILanguage>en-US</UILanguage>
<UserLocale>en-US</UserLocale>
</component>
<component name="Microsoft-Windows-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">
<DiskConfiguration>
<Disk wcm:action="add">
<CreatePartitions>
<CreatePartition wcm:action="add">
<Size>250</Size>
<Order>1</Order>
<Type>Primary</Type>
</CreatePartition>
<CreatePartition wcm:action="add">
<Order>2</Order>
<Extend>true</Extend>
<Type>Primary</Type>
</CreatePartition>
</CreatePartitions>
<ModifyPartitions>
<ModifyPartition wcm:action="add">
<Order>1</Order>
<PartitionID>1</PartitionID>
<Format>NTFS</Format>
<Label>Boot</Label>
<Active>true</Active>
</ModifyPartition>
<ModifyPartition wcm:action="add">
<Order>2</Order>
<PartitionID>2</PartitionID>
<Format>NTFS</Format>
<Label>System</Label>
</ModifyPartition>
</ModifyPartitions>
<DiskID>0</DiskID>
<WillWipeDisk>true</WillWipeDisk>
</Disk>
</DiskConfiguration>
<ImageInstall>
<OSImage>
<InstallFrom>
<MetaData wcm:action="add">
<Key>/IMAGE/NAME</Key>
<Value>Windows Server 2022 SERVERSTANDARD</Value>
</MetaData>
</InstallFrom>
<InstallTo>
<DiskID>0</DiskID>
<PartitionID>2</PartitionID>
</InstallTo>
<WillShowUI>OnError</WillShowUI>
<InstallToAvailablePartition>false</InstallToAvailablePartition>
</OSImage>
</ImageInstall>
<UserData>
<AcceptEula>true</AcceptEula>
<ProductKey>
<WillShowUI>Never</WillShowUI>
<Key>VDYBN-27WPP-V4HQT-9VMD4-VMK7H</Key>
</ProductKey>
</UserData>
</component>
</settings>
<settings pass="specialize">
<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">
<TimeZone>GMT Standard Time</TimeZone>
<DisableAutoDaylightTimeSet>false</DisableAutoDaylightTimeSet>
</component>
<component name="Microsoft-Windows-TerminalServices-LocalSessionManager" 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">
<fDenyTSConnections>false</fDenyTSConnections>
</component>
<component name="Networking-MPSSVC-Svc" 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">
<FirewallGroups>
<FirewallGroup wcm:action="add" wcm:keyValue="RemoteDesktop">
<Active>true</Active>
<Group>Remote Desktop</Group>
<Profile>all</Profile>
</FirewallGroup>
</FirewallGroups>
</component>
<component name="Microsoft-Windows-TerminalServices-RDP-WinStationExtensions" 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">
<SecurityLayer>2</SecurityLayer>
<UserAuthentication>1</UserAuthentication>
</component>
<component name="Microsoft-Windows-ServerManager-SvrMgrNc" 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">
<DoNotOpenServerManagerAtLogon>true</DoNotOpenServerManagerAtLogon>
</component>
</settings>
<settings pass="oobeSystem">
<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">
<AutoLogon>
<Username>Administrator</Username>
<Enabled>true</Enabled>
<LogonCount>2</LogonCount>
<Password>
<Value>PASSWORD</Value>
<PlainText>true</PlainText>
</Password>
</AutoLogon>
<FirstLogonCommands>
<SynchronousCommand wcm:action="add">
<Order>1</Order>
<CommandLine>powershell -ExecutionPolicy Bypass -File f:\install-vmware-tools-from-iso.ps1</CommandLine>
<Description>Enable WinRM service</Description>
<RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand>
</FirstLogonCommands>
<UserAccounts>
<AdministratorPassword>
<Value>PASSWORD</Value>
<PlainText>true</PlainText>
</AdministratorPassword>
<LocalAccounts>
<LocalAccount wcm:action="add">
<Name>Admin</Name>
<Group>Administrators</Group>
<Password>
<Value>PASSWORD</Value>
<PlainText>true</PlainText>
</Password>
</LocalAccount>
<LocalAccount wcm:action="add">
<Name>User</Name>
<Group>Users</Group>
<Password>
<Value>password</Value>
<PlainText>true</PlainText>
</Password>
</LocalAccount>
</LocalAccounts>
</UserAccounts>
</component>
</settings>
<cpi:offlineImage cpi:source="wim:c:/wims/install.wim#Windows Server 2022 SERVERDATACENTER" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
</unattend>
i got this issue everytime :
==> win2022.vsphere-iso.ws2022: Typing boot command...
==> win2022.vsphere-iso.ws2022: Waiting for IP...
==> win2022.vsphere-iso.ws2022: Clearing boot order...
==> win2022.vsphere-iso.ws2022: Powering off virtual machine...
==> win2022.vsphere-iso.ws2022: Destroying VM...
==> win2022.vsphere-iso.ws2022: Removing [_ESXI04_DS_SSD_RAID1] packer_cache/packer3590941043.iso...
win2022.vsphere-iso.ws2022: Closing sessions ....
Build 'win2022.vsphere-iso.ws2022' errored after 1 minute 27 seconds: Post "https://vcntr-vroot.local/sdk": unexpected EOF
Further information :
packer version : Packer v1.11.1
Packer OS : Ubuntu
Target OS : Windows Server 2022 Standard
ESXI Server : VMware ESXi, 7.0.3, 19482537
Can anyone help me figure this out?