Closed dnmgns closed 9 years ago
I can't easily tell how you've customized packer-windows-templates. Would you consider forking from the original? Meanwhile, I can try reproducing a chocolatey install. I realize Chocolatey has changed quite a bit in the last couple months.
Thanks for your reply Dylan! I'd be very happy if you tried reproducing.
There's only minor changes that I've performed: './scripts/chocolatey.ps1' => Tried a new approach for installing chocolatey. (It fails with both this approach and the initial one from your repo) 'windows_2008_r2/Autounattended.xml.template' => Renamed to Autounattended.xml and using without windows updates instead of with windows updates. 'windows_2008_r2/vbox-iso.json' => Using a windows_2008_r2 trial ISO, tried with 3 different ones including the one that was referenced in your json file.
I can also fork from the original in case you can't reproduce.
I saw the Chocolatey change but failed to realize we were talking about windows_2008_r2. Chocolatey requires .NET 4 so on Windows 2008 R2 it's trying to install it as part of its own install and failing for some reason. I'll see what I can find out....
Inexplicably, the "elevated" directives (which run commands as scheduled tasks) prevent this acl/permissions code in the Chocolatey install process from running correctly: https://github.com/chocolatey/choco/blob/9775c21e82ad9676d8f7c33a4322eb053ea3b443/nuget/chocolatey/tools/chocolateysetup.psm1#L172-L189
Thankfully, with the new and improved Chocolatey, we don't need to run with the "elevated" directives. The following works peachy keen on Windows 2008 R2 and I'll be verifying this on 2012 as well:
{
"type": "powershell",
"inline": [
"iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))",
"choco install -y netfx-4.5.2-devpack"
]
}
Let me know how it goes.
Good find! Seems very promising. I'll try this out in a couple of hours, will let you know my results!
Still no luck for me unfortunately. I cloned your repository, commented out the windows update and used the trial iso (same changes that I did earlier) and this time I got a different error message.
virtualbox-windows-ovf: Install-DotNet4IfMissing : .NET Framework install failed with exit code '5'
Seems that exit code 5 = 'Access is denied. Indicates that user has no access right to specified resource'.
https://gist.github.com/dnmgns/927743bd9b4084fc80e7#file-packer-log-L217
Note: This time I tried it at another computer, with packer-win-plugin 1.0.0. I'll try it again tomorrow at the computer where I initially experienced this issue. I'll let you know if there's any different result there. In case it still fails I'll fork your repo, make my changes and reproduce.
We got past the Chocolatey part.
I think the Widows Updates were already installing 4.5.2 for me, so I was just Chocolatey installing the devpack on top of an existing 4.5.2. But if you're running without those Windows Updates, then I think this is what we want:
{
"type": "powershell",
"inline": ["iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))"]
}, {
"type": "powershell",
"elevated_user": "packer",
"elevated_password": "packer",
"inline": [
"choco install -y netfx-4.5.2-devpack"
]
}
The elevated stuff is slower so I wanted to avoid it, but for a full .NET install it's likely still required.
Unfortunately Chocolatey is still throwing errors at me.
Throwing error at https://gist.github.com/dnmgns/c2065fd38d7fedd3dc1c#file-packer-log-L306
So I'm still stuck at this point of the Chocolatey installation: https://github.com/chocolatey/choco/blob/9775c21e82ad9676d8f7c33a4322eb053ea3b443/nuget/chocolatey/tools/chocolateysetup.psm1#L486
No idea why, I'll try with running the windows update just to get past this.
Ok. Well I think we are in the uncomfortable position of
Run through your scenario with full on Windows Updates for 2008 R2, confirm that 1-3 appear true, and I will create a separate, Chocolatey bug to track that issue. Otherwise, well... let's see. :)
Any luck @dnmgns?
I'm considering breaking this issue down into this one concern: Can't install Chocolatey v0.9.9 with "elevated" shell provisioners
According to https://github.com/WinRb/vagrant-windows/issues/18. we should ensure UAC is disabled for chocolatey to do its business.
UAC is disabled. Seems that I can't install .net framework in any way either. Windows will not let me enable the feature, and running the offline installation fails. Installer just hangs after starting to load some MSU-file. Tried with winrm, windows-shell, powershell and shell.
And windows update never completes, kept waiting for about 10 hours. Download speed is fine, so no idea why yet.
It seems I'm having some bad luck. I'll run some more tests and see what I can find.
Feel free to close the issue. And thanks for all your valuable input!
On 29 May 2015, at 16:54, Dylan Meissner notifications@github.com wrote:
According to WinRb/vagrant-windows#18. we should ensure UAC is disabled for chocolatey to do its business.
— Reply to this email directly or view it on GitHub.
@dnmgns did you work out how to solve this issue? I'm having the exact same problem using Packer provisioners to install chocolatey on 2008-R2. What's strange is that I can installation works fine if i log on to the box and type the same commands manually.
This works for me on Win2008R2:
"provisioners": [
{
"inline": [
"iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))",
"choco install -y powershell4"
],
"valid_exit_codes": [0, 3010],
"elevated_user": "vagrant",
"elevated_password": "vagrant",
"type": "powershell"
},
{
"type": "windows-restart"
}
],
I'm having some troubles getting chocolatey to install properly when using powershell elevated provisioner. I'm really not quite sure whether this is a specific Windows issue, chocolatey issue or if it's related to the packer windows plugin itself. But hopefully you'll be able to help point me in the right direction as I'm completely stuck at this point.
Background & issue explanation: I've cloned https://github.com/dylanmei/packer-windows-templates and made some minor changes.
When trying to run the chocolatey ps1 script, I'm getting a 'Script exited with non-zero exit status: 1.' error.
This issue is both reproducible with the current packer-windows-plugin pre-release (darwin_amd64.zip, e727a2c) and latest brew installation (v 1.0.0). Running the chocolatey installation manually from powershell with the ps1 script with the packer user on the virtual machine is successful.
I thought that this might be an issue with the chocolatey script returning incorrect exit code, so I've tried with accepting 1 as the exit code. This way, I could verify that the installation fails, so the exit code is correct.
This is reproducible both with VirtualBox and VMWare so the virtual machine software doesn't seem to be the issue here.
C:\Chocolatey\ folder is never created. The .NET package (dotNetFx40_Full_x86_x64.exe) gets installed successfully.
Packer build log: https://gist.github.com/dnmgns/fc842b59f5f837bd949d#file-fail-log Packer crash log: https://gist.github.com/dnmgns/0699187f627ad1d93d0e#file-crash-log
To reproduce: git clone https://github.com/dnmgns/packer-windows-templates.git; cd packer-windows-templates packer build windows_2008_r2/vbox-iso.json packer build windows_2008_r2/vbox-ovf.json
Any ideas about what to try next and what might be causing this issue is much appreciated!