Hi,
I’m trying to create Win11 ami with vSphere hypervisor.
in the last step of the build, I get this error every time.
FirstBootFailure: This import request failed because the instance failed to boot and establish network connectivity.
Maybe I missed something that related to Win11 disk encryption in AWS configuration?
Here is the JSON I’m using:
{
"builders": [
{
"type": "qemu",
"accelerator": "kvm",
"boot_wait": "5m",
"disk_compression": "{{ user `compress`}}",
"disk_size": "{{user `disk_size`}}",
"format": "{{user `disk_format`}}",
"floppy_files": "{{ user `floppy_files_list` }}",
"headless": true,
"iso_checksum": "{{ user `iso_checksum_type` }}:{{ user `iso_checksum` }}",
"iso_urls": [
"{{ user `iso_url` }}"
],
"output_directory": "output-{{user `name`}}",
"qemuargs": [
[
"-m",
"8192M"
],
[
"-cpu",
"Westmere"
],
[
"-m",
"{{ user `memory` }}"
],
[
"-smp",
"cpus={{ user `cpus`}}"
]
],
"shutdown_command": "C:\\Windows\\packer\\shutdown.bat",
"shutdown_timeout": "1h",
"vm_name": "{{user `name`}}",
"communicator": "winrm",
"winrm_insecure": "true",
"winrm_use_ssl": "true",
"winrm_username": "{{user `packer_user`}}",
"winrm_password": "{{user `packer_pass`}}",
"winrm_port": "5986",
"winrm_timeout": "4h"
},
{
"type": "vsphere-iso",
"vm_name": "{{user `name`}}-{{user `tag`}}",
"CPUs": "{{user `cpus`}}",
"RAM": "{{user `memory`}}",
"RAM_reserve_all": true,
"communicator": "winrm",
"convert_to_template": "{{user `vsphere-maketemplate`}}",
"cluster": "{{user `vsphere-cluster`}}",
"datacenter": "{{user `vsphere-datacenter`}}",
"datastore": "{{user `vsphere-datastore`}}",
"username": "{{user `vsphere-user`}}",
"vcenter_server": "{{user `vsphere-server`}}",
"disk_controller_type": "{{user `vmware_disk_controller_type`}}",
"firmware": "bios",
"floppy_files": "{{ user `floppy_files_list` }}",
"folder": "{{user `vsphere-folder`}}",
"guest_os_type": "{{user `vmware_guest_os_type`}}",
"insecure_connection": "true",
"shutdown_command": "C:\\Windows\\packer\\shutdown.bat",
"shutdown_timeout": "1h",
"iso_checksum": "{{user `iso_checksum_type` }}:{{ user `iso_checksum` }}",
"iso_paths": [
"[] /vmimages/tools-isoimages/windows.iso"
],
"iso_urls": [
"{{ user `iso_url` }}"
],
"network_adapters": [
{
"network": "{{user `vsphere-network`}}",
"network_card": "{{user `vmware_network_card`}}"
}
],
"password": "{{user `vsphere-password`}}",
"storage": [
{
"disk_size": "{{user `disk_size`}}",
"disk_thin_provisioned": true
}
],
"winrm_timeout": "4h",
"winrm_use_ssl": "false",
"winrm_insecure": "true",
"winrm_password": "{{user `packer_pass`}}",
"winrm_username": "{{user `packer_user`}}"
}
],
"provisioners": [
{
"scripts": [
"scripts/uac-disable.bat",
"scripts/disable-hibernate.bat"
],
"type": "windows-shell"
},
{
"pause_before": "10s",
"type": "powershell",
"elevated_user":"{{user `packer_user`}}",
"elevated_password": "{{user `packer_pass`}}",
"scripts": [
"scripts/dis-updates.ps1",
"scripts/phase1.ps1",
"scripts/set_firewall_rules.ps1",
"scripts/phase2.ps1"
]
},
{
"type": "windows-restart",
"restart_timeout": "2h",
"restart_check_command": "powershell -command \"& {Write-Output 'restarted.'}\""
},
{
"type": "powershell",
"elevated_user":"{{user `packer_user`}}",
"elevated_password": "{{user `packer_pass`}}",
"scripts": [
"scripts/phase3.ps1"
]
},
{
"type": "windows-restart",
"restart_timeout": "2h",
"restart_check_command": "powershell -command \"& {Write-Output 'restarted.'}\""
},
{
"type": "powershell",
"elevated_user":"{{user `packer_user`}}",
"elevated_password": "{{user `packer_pass`}}",
"scripts": [
"scripts/install-choco.ps1",
"scripts/Set-PowerSettings.ps1",
"scripts/Set-WindowsTelemetrySettings.ps1"
]
},
{
"type": "windows-restart",
"restart_timeout": "2h",
"restart_check_command": "powershell -command \"& {Write-Output 'restarted.'}\""
},
{
"inline": [
"Write-Host \"Installing Tools\"",
"choco install googlechrome 7zip notepadplusplus choco-cleaner git.install procexp",
"New-Item -Path 'C:\\Windows\\Setup\\Scripts' -ItemType Directory -Force",
"New-Item -Path \"C:\\Windows\\packer\" -ItemType Directory -Force"
],
"type": "powershell",
"elevated_user":"{{user `packer_user`}}",
"elevated_password": "{{user `packer_pass`}}"
},
{
"type": "file",
"sources": [
"{{user `sysprep_auto_unattended`}}",
"scripts/shutdown.bat",
"scripts/install_aws_components.ps1",
"scripts/uninstall-vmwaretools.ps1",
"scripts/SetupComplete_noaws.cmd",
"scripts/SetupComplete_aws.cmd"
],
"destination": "C:\\Windows\\packer\\"
},
{
"type": "file",
"source": "scripts/bginfo.bgi",
"destination": "C:\\ProgramData\\chocolatey\\lib\\bginfo\\Tools\\"
},
{
"type": "powershell",
"environment_vars": [
"AWS={{ user `enable_aws_tool`}}"
],
"inline": [
"if ($Env:AWS -eq \"true\" ) { . C:\\Windows\\packer\\install_aws_components.ps1}",
"if ($Env:AWS -eq \"true\" ) { Copy-Item -Path C:\\Windows\\packer\\SetupComplete_aws.cmd C:\\Windows\\Setup\\Scripts\\SetupComplete.cmd } else { choco install bginfo ; Copy-Item -Path C:\\Windows\\packer\\SetupComplete_noaws.cmd C:\\Windows\\Setup\\Scripts\\SetupComplete.cmd}"
]
},
{
"inline": [
"Remove-AppxPackage -Package 'Microsoft.OneDriveSync_21220.1024.5.0_neutral__8wekyb3d8bbwe' -AllUsers",
"Get-Service -Name wuauserv | Stop-Service",
"Get-Service -Name wuauserv | Set-Service -StartupType disabled",
"net stop bits",
"net stop dosvc"
],
"type": "powershell",
"elevated_user":"{{user `packer_user`}}",
"elevated_password": "{{user `packer_pass`}}"
},
{
"script": "scripts/cleanup.ps1",
"type": "powershell"
}
],
"post-processors": [
[
{
"type": "shell-local",
"name": "fix-output-qcow2",
"only": [
"qemu"
],
"inline": [
"mkdir -p output",
"mv output-{{user `name`}}/{{user `name`}} output/{{user `name`}}-{{user `tag`}}.qcow2",
"rm -rvf output-{{user `name`}}/"
]
},
{
"type": "shell-local",
"name": "gcp",
"only": [
"qemu"
],
"inline": [
"mv output-{{user `name`}}/{{user `name`}} disk.raw",
"tar -cf - disk.raw |pigz > {{user `name`}}.tar.gz",
"rm -vf disk.raw",
"gsutil cp {{user `name`}}.tar.gz gs://{{user `gcs_bucket`}}/{{user `name`}}-{{user `tag`}}.tar.gz",
"gcloud compute images create {{user `name`}}-{{user `tag`}} \\",
"--source-uri=gs://{{user `gcs_bucket`}}/{{user `name`}}-{{user `tag`}}.tar.gz \\",
"--family={{user `name`}}",
"rm -rvf output-{{user `name`}}/",
"rm -vf {{user `name`}}.tar.gz"
]
},
{
"type": "shell-local",
"name": "export-ovf",
"only": [
"vsphere-iso"
],
"environment_vars": [
"GOVC_INSECURE=1",
"GOVC_URL={{user `vsphere-server`}}",
"GOVC_CLUSTER={{user `vsphere-cluster`}}",
"GOVC_RESOURCE_POOL=\"*/Resources\"",
"GOVC_USERNAME={{user `vsphere-user`}}",
"GOVC_PASSWORD={{user `vsphere-password`}}"
],
"inline": [
"govc export.ovf -sha=1 -vm={{user `name`}}-{{user `tag`}} ."
]
},
{
"type": "shell-local",
"only": [
"vsphere-iso"
],
"inline": [
"mv {{user `name`}}-{{user `tag`}}/{{user `name`}}-{{user `tag`}}-disk-0.vmdk .",
"rm -rvf {{user `name`}}-{{user `tag`}}"
]
},
{
"only": [
"vsphere-iso"
],
"files": [
"{{user `name`}}-{{user `tag`}}-disk-0.vmdk"
],
"type": "artifice"
},
{
"type": "amazon-import",
"only": [
"vsphere-iso"
],
"name": "aws",
"access_key": "Key",
"secret_key": "Key",
"region": "{{user `aws_region`}}",
"s3_bucket_name": "{{user `aws_s3_bucket_name`}}",
"s3_key_name": "{{user `name`}}-{{user `tag`}}-disk-0.vmdk",
"format": "vmdk",
"license_type": "BYOL",
"aws_polling": {
"delay_seconds": 30,
"max_attempts": 200
},
"tags": {
"Description": "packer amazon-import {{user `name`}}-{{user `tag`}}.ova"
}
},
{
"type": "shell-local",
"name": "cleanup-aws",
"only": [
"vsphere-iso"
],
"inline": [
" rm -vf {{user `name`}}-{{user `tag`}}-disk-0.vmdk"
]
}
]
]
}