0

I'm trying to use virtualbox+packer+vagrant to automate the provisioning of VMs.

I've got the json template setup to show the VM UI (so headless=false), and configured the autounattend.xml with my ISO key and the OpenSSH Server option to be installed as first.

The issue is that the vm creation get stuck on the "Waiting for SSH" log entry, I can see the VM running and the prompt for entering the Windows Key but nothing else happen.

Any help is appreciated

this is the output up to that point from packer build, at which point I've aborted the installation

PS C:\Users\xxxxxxx\Documents\DevVM> packer build .\windows_2012_r2.json 
virtualbox-iso output will be in this color.
==> virtualbox-iso: Downloading or copying Guest additions
    virtualbox-iso: Downloading or copying: file:///C:/Program%20Files/Oracle/VirtualBox/VBoxGuestAdditions.iso
==> virtualbox-iso: Downloading or copying ISO
    virtualbox-iso: Downloading or copying: file:///C:/Users/xxxxxxx/Documents/Work/VMs/ISOs/en_windows_server_2012_r2_x64_dvd_2707946.iso
==> virtualbox-iso: Creating floppy disk...
    virtualbox-iso: Copying: C:/Users/xxxxxxx/Documents/DevVM/Autounattend.xml
    virtualbox-iso: Copying: C:/Users/xxxxxxx/Documents/DevVM/GitHub/packer-windows/scripts/microsoft-updates.bat
    virtualbox-iso: Copying: C:/Users/xxxxxxx/Documents/DevVM/GitHub/packer-windows/scripts/win-updates.ps1
    virtualbox-iso: Copying: C:/Users/xxxxxxx/Documents/DevVM/GitHub/packer-windows/scripts/openssh.ps1
    virtualbox-iso: Copying: C:/Users/xxxxxxx/Documents/DevVM/GitHub/packer-windows/scripts/oracle-cert.cer
==> virtualbox-iso: Creating virtual machine...
==> virtualbox-iso: Creating hard drive...
==> virtualbox-iso: Attaching floppy disk...
==> virtualbox-iso: Creating forwarded port mapping for SSH (host port 4430)
==> virtualbox-iso: Executing custom VBoxManage commands...
    virtualbox-iso: Executing: modifyvm packer-virtualbox-iso-1443107958 --memory 2048
    virtualbox-iso: Executing: modifyvm packer-virtualbox-iso-1443107958 --cpus 2
==> virtualbox-iso: Starting the virtual machine...
==> virtualbox-iso: Waiting 2m0s for boot...
==> virtualbox-iso: Typing the boot command...
==> virtualbox-iso: Waiting for SSH to become available...
==> virtualbox-iso: Unregistering and deleting virtual machine...
==> virtualbox-iso: Deleting output directory...
Build 'virtualbox-iso' errored: Build was cancelled.
Cleanly cancelled builds after being interrupted.

This is the autounattend.xml part with the openssh entry

 <FirstLogonCommands>
            <SynchronousCommand wcm:action="add">
                <CommandLine>cmd.exe /c C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -File a:\openssh.ps1 -AutoStart</CommandLine>
                <Description>Install OpenSSH</Description>
                <Order>1</Order>
                <RequiresUserInput>true</RequiresUserInput>
            </SynchronousCommand>                

I've also tried to change the order of the above as last command (order=23) but with no effect.

This is a part of the json template

      "type": "virtualbox-iso",
  "iso_url": "C:/Users/xxxxxx/Documents/Work/VMs/ISOs/en_windows_server_2012_r2_x64_dvd_2707946.iso",
  "iso_checksum_type": "md5",
  "iso_checksum": "0e7c09aab20dec3cd7eab236dab90e78",
  "headless": false,
  "boot_wait": "2m",
  "ssh_username": "vagrant",
  "ssh_password": "vagrant",
  "ssh_wait_timeout": "10m",
  "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"",
  "guest_os_type": "Windows2012_64",
  "disk_size": 61440,
  "floppy_files": [
    "C:/Users/xxxxxx/Documents/DevVM/Autounattend.xml",
    "C:/Users/xxxxxx/Documents/DevVM/GitHub/packer-windows/scripts/microsoft-updates.bat",
    "C:/Users/xxxxxx/Documents/DevVM/GitHub/packer-windows/scripts/win-updates.ps1",
    "C:/Users/xxxxxx/Documents/DevVM/GitHub/packer-windows/scripts/openssh.ps1",
    "C:/Users/xxxxxx/Documents/DevVM/GitHub/packer-windows/scripts/oracle-cert.cer"
  ],

1 Answer 1

0

Try increasing the ssh_wait_timeout from 10m to 2h in your json template

What seems to be this issue is that the system has not had sufficient time to boot and have a configuration for SSH to be ready. Setting this time to something more reasonable should work.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .