Packer Stops running line in a .bat file

540 views
Skip to first unread message

Gergely Brautigam

unread,
Jun 26, 2015, 2:59:39 AM6/26/15
to packe...@googlegroups.com
Hello folks.

I have a very interesting situation. I have a massive Windows box building up. I extracted many steps into the Answer file because they need re-starts and I haven't found any very clean solution when building up a windows box on restarts in the provision phase. I saw there are time-outs and tries to start a new SSHD session, but that never worked for me. It stopped on executing a provision and just stays there and waits indefinitely.

Anyhow, my final problem in setting up this massive frigging box, is very puzzling and I really am out of ideas here. Once this is solved, I can put this thing into production so REALLY please, I need help with this. :)

I'm trying to provision visual studio 2013 which would work fine with choco actually, if it would execute every line in my BAT file. It appears to be a very simple thing.

This is my provision:
  "provisioners": [
    {
      "type": "shell",
      "remote_path": "/tmp/script.bat",
      "execute_command": "{{.Vars}} cmd /c C:/Windows/Temp/script.bat",
      "scripts": [
        "./scripts/vm-guest-tools.bat",
        "./scripts/puppet.bat",
        "./scripts/vagrant-ssh.bat",
        "./scripts/rsync.bat",
        "./scripts/wget.bat",
        "./scripts/enable-rdp.bat",
        "./scripts/init.bat",
        "./scripts/jdk_inst.bat",
        "./scripts/office_2007_inst.bat",
        "./scripts/vs2013.bat"        
      ]
    }

And this is all there is in the vs2013.bat file:
choco install visualstudio2013ultimate -y
choco install vs2013.4 -y

THAT is it. There is nothing more. I swear.

Now, the first line executes successfully without any problems. It even updates dotnet framework from 4.5.0 to 4.5.1 so everything is awesome. And then it gets to the second line. And stays there. Indefinitely. Without any log output. Just stays there. I realized that it could take a while perhaps, so I left the box here over the night came back, saw the same log line, moving not an inch. Relentlessly staring at me. Mocking me with eyes made by the Devil saying: Choco installing vs2013.4 -y...

Please, I implore you. If you have any advice.... It would be welcomed likes a hot cup of Earl Gray in a stormy night in and old building in the middle of England.

Thank you very much!
Gergely.

Gergely Brautigam

unread,
Jun 26, 2015, 3:36:25 AM6/26/15
to packe...@googlegroups.com
Tried it with call, appears to be the same result =>

1435303884,,ui,message,    virtualbox-iso: By installing you accept licenses for the packages.
1435303897,,ui,message,    virtualbox-iso:
1435303897,,ui,message,    virtualbox-iso: DotNet4.5.1 v4.5.1.20140606
1435303901,,ui,message,    virtualbox-iso: Downloading dotnet451 32 bit
1435303901,,ui,message,    virtualbox-iso: from 'http://download.microsoft.com/download/7/4/0/74078A56-A3A1-492D-BBA9-865684B83C1B/NDP451-KB2859818-Web.exe'
1435303903,,ui,message,    virtualbox-iso: Installing dotnet451...
1435304012,,ui,message,    virtualbox-iso:
1435304012,,ui,message,    virtualbox-iso: C:\Users\vagrant>call choco install vs2013.4 -y

Gergely Brautigam

unread,
Jun 26, 2015, 5:54:40 AM6/26/15
to packe...@googlegroups.com
I have tried to put it out of choco and use call and everything.

It STOPS after the download. It does not execute the EXE.

1435312357,,ui,message,    virtualbox-iso: C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\ProgramData\chocolatey\bin;C:\Program Files\OpenSSH\bin;C:\Program Files\OpenSSH\bin
1435312357,,ui,say,==> virtualbox-iso: Provisioning with shell script: ./scripts/vs2013-nochoco.bat
1435312357,,ui,message,    virtualbox-iso:
1435312357,,ui,message,    virtualbox-iso: C:\Users\vagrant>call powershell -NoProfile -ExecutionPolicy unrestricted -Command "(New-Object System.Net.WebClient).DownloadFile('http://download.microsoft.com/download/C/F/B/CFBB5FF1-0B27-42E0-8141-E4D6DA0B8B13/vs_ultimate_download.exe'%!(PACKER_COMMA) 'C:\Windows\Temp\vs_ultimate_download.exe')"

Content of BAT:
call powershell -NoProfile -ExecutionPolicy unrestricted -Command "(New-Object System.Net.WebClient).DownloadFile('http://download.microsoft.com/download/C/F/B/CFBB5FF1-0B27-42E0-8141-E4D6DA0B8B13/vs_ultimate_download.exe', 'C:\Windows\Temp\vs_ultimate_download.exe')"
echo "Finished downloading visual studio ultimate."
call C:\Windows\Temp\vs_ultimate_download.exe /adminfile a:\admin_install.xml /quite /norestart
echo "Finished executing visual studio ultimate."
call powershell -NoProfile -ExecutionPolicy unrestricted -Command "(New-Object System.Net.WebClient).DownloadFile('http://download.microsoft.com/download/9/4/3/9430B009-5E55-4D48-ADA6-CBC1E025573E/VS2013.4.exe', 'C:\Windows\Temp\VS2013.4.exe')"
echo "Finished downlading update."
call C:\Windows\Temp\VS2013.exe /Passive /NoRestart
echo "Finished running update."

It looks like as if the EXE is not executed at all.

Alvaro Miranda Aguilera

unread,
Jun 29, 2015, 1:27:21 AM6/29/15
to packe...@googlegroups.com
Have you got any progress on this? or still stuck somewhere?
> --
> This mailing list is governed under the HashiCorp Community Guidelines -
> https://www.hashicorp.com/community-guidelines.html. Behavior in violation
> of those guidelines may result in your removal from this mailing list.
>
> GitHub Issues: https://github.com/mitchellh/packer/issues
> IRC: #packer-tool on Freenode
> ---
> You received this message because you are subscribed to the Google Groups
> "Packer" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to packer-tool...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/packer-tool/bdd2c2e5-ce3e-46a4-b93a-89aeb4a3d027%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

Gergely Brautigam

unread,
Jun 29, 2015, 4:04:24 AM6/29/15
to packe...@googlegroups.com
Still stuck. I tried now windows powershell provisioner and windows shell provisioner as well.

Still stuck here: =>

1435564778,,ui,message,    virtualbox-iso: command shell to restart it.
1435564781,,ui,message,    virtualbox-iso: Downloading 7zip.install 64 bit
1435564781,,ui,message,    virtualbox-iso: from 'http://www.7-zip.org/a/7z938-x64.msi'
1435564783,,ui,message,    virtualbox-iso: Installing 7zip.install...
1435564784,,ui,message,    virtualbox-iso: 7zip.install has been installed.

And nothing after... :(

Gergely Brautigam

unread,
Jun 29, 2015, 5:06:53 AM6/29/15
to packe...@googlegroups.com
I don't get this.

I changed to a powershell script to install wget. First, it worked. Now it isn't working. It gets stuck after this line =>

1435568594,,ui,message,    virtualbox-iso: Starting installation process...
1435568594,,ui,message,    virtualbox-iso:
1435568594,,ui,message,    virtualbox-iso: Handles  NPM(K)    PM(K)      WS(K) VM(M)   CPU(s)     Id ProcessName
1435568594,,ui,message,    virtualbox-iso: -------  ------    -----      ----- -----   ------     -- -----------
1435568594,,ui,message,    virtualbox-iso: 0       2      380        116     5     0.00   2372 wget


And is no longer doing anything, although I can see that the CPU is at 100% like a motherf*cker. But I bet you I can leave now, come back in an hour and it would still be stuck there.

Here is the install script:

    (New-Object System.Net.WebClient).DownloadFile('http://downloads.sourceforge.net/gnuwin32/wget-1.11.4-1-setup.exe', 'C:\Windows\Temp\wget.exe')
    (New-Object System.Net.WebClient).DownloadFile('http://downloads.sourceforge.net/sevenzip/7z920-x64.msi', 'C:\Windows\Temp\7zip.msi')
    Start-Process -FilePath "C:\Windows\Temp\wget.exe" -ArgumentList "/VERYSILENT" -Wait -PassThru
    &msiexec /i "C:\Windows\Temp\7zip.msi" INSTALLDIR='C:\Program Files\7-Zip' /qb

Nothing fancy. :(

Gergely Brautigam

unread,
Jun 29, 2015, 5:25:21 AM6/29/15
to packe...@googlegroups.com
If I shift this into the answer file and let windows set it up, it's all fine, so I know the script is okay.

Even further, if I ran it manually on a windows box, it's all fine as well.

So.... I don't know. What could this be?

Or is there any log I can look at? Headless mode false => Can't see anything on the box. In debug mode, nothing special either.

I tried adding CALL, I tried avoiding BAT files. I don't know at this point. I'm getting frustrated. I would like to do this the nice, working way, rather than a hacky way.

Gergely Brautigam

unread,
Jul 1, 2015, 3:22:29 AM7/1/15
to packe...@googlegroups.com
*SOLVED*!!!

I just updated to Packer 0.8.1. All the hangs and problems are gone. Everything is as smooth as a baby's bum! AWESOME!!
Reply all
Reply to author
Forward
0 new messages