I was able to install guest additions, share folders but packer hangs when I try to uninstall guest additions as the last step.
Here is my packer template
{
"variables": {
"guest_additions_mode": "attach",
"headless": "false",
"short_name": "Win10Enterprise_x64",
"software_packages_path": "software_packages"
},
"builders": [{
"type": "virtualbox-ovf",
"source_path": "output/updated/{{ user `short_name` }}_updated.ovf",
"output_directory": "output/with_software/",
"vm_name": "{{ user `short_name` }}_with_software",
"vboxmanage": [
["modifyvm", "{{.Name}}", "--memory", "4096"],
["modifyvm", "{{.Name}}", "--vram", "48"],
["modifyvm", "{{.Name}}", "--cpus", "1"],
["sharedfolder", "add", "{{.Name}}", "--name", "software_packages", "--hostpath", "{{ user `software_packages_path` }}"]
],
"guest_additions_mode": "{{ user `guest_additions_mode` }}",
"headless": "{{ user `headless` }}",
"communicator": "winrm",
"winrm_username": "Administrator",
"winrm_password": "******",
"winrm_timeout": "12h",
"winrm_port": 5985,
"shutdown_command": "shutdown /s /t 10 /f /d p:4:1",
"post_shutdown_delay": "5m",
"floppy_dirs": ["scripts"]
}],
"provisioners": [{
"type": "powershell",
"script": "scripts/install_software_pkgs/install_oracle_guest_additions.ps1"
},
{
"type": "windows-restart",
"restart_timeout": "2h"
},
{
"type": "powershell",
"inline": "scripts/install_software_pkgs/uninstall_guest_additions.ps1"
},
{
"type": "windows-restart",
"restart_timeout": "2h"
}
]
}
$path = $null
if (Test-Path "d:\VBoxWindowsAdditions.exe") {
$path = "d:\VBoxWindowsAdditions.exe"
}
elseif (Test-Path "e:\VBoxWindowsAdditions.exe") {
$path = "e:\VBoxWindowsAdditions.exe"
}
else{
write-host "no guest additions drive found"
exit
}
write-host "uninstalling guest additions"
& $path '/uninstall'
#Wait for 2 minutes to make sure that it is uninstalled successfully
write-host "wait for 2 minutes before exiting the script"
start-sleep -s 120