Comments (8)
I've been adding chocolatey packages on the vagrant side with puppet and the puppet-chocolatey module. That works on 2008 r2 and 2012 with KB2842230 applied to fix a WinRM issue.
What you are doing should work too. I'm on a trip with only an iPad until Sunday. Is there any extra output you can share?
Finally, you might try adding Chocolatey earlier from the Autounattend.xml with a ps script such as https://github.com/ferventcoder/puppet-windows-presentation/blob/master/Demo/shell/InstallChocolatey.ps1.
from packer-windows.
I agree - I would keep the Packer box as bare-bones as possible, and then focus on using Vagrant (using your box build with Packer) to install chocolatey and then packages using it. I created this cookbook to allow you to specify an array of packages to install: https://github.com/joefitzgerald/chocolatey-installer - just make sure you also use https://github.com/chocolatey/chocolatey-cookbook too.
Berksfile: https://gist.github.com/joefitzgerald/6253333
Vagrantfile: https://gist.github.com/joefitzgerald/6253368
sysprep-and-seal.ps1: https://gist.github.com/joefitzgerald/6254582
from packer-windows.
This is part of the log
C:\Users\vagrant>cinst nodejs.install
vmware: Chocolatey (v0.9.8.20) is installing nodejs.install and dependencies. By installing you accept the license for nodejs.install and each dependency you are installing.
vmware: Join-Path : Cannot bind argument to parameter 'Path' because it is null.
vmware: At C:\Chocolatey\chocolateyinstall\functions\Get-UserConfigValue.ps1:11 char:37
vmware: + $userConfigFile = Join-Path $env:USERPROFILE chocolatey.config
vmware: + ~~~~~~~~~~~~~~~~
vmware: + CategoryInfo : InvalidData: (:) [Join-Path], ParameterBindingVa
vmware: lidationException
vmware: + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,M
vmware: icrosoft.PowerShell.Commands.JoinPathCommand
vmware:
vmware: Test-Path : Cannot bind argument to parameter 'Path' because it is null.
vmware: At C:\Chocolatey\chocolateyinstall\functions\Get-UserConfigValue.ps1:13 char:27
vmware: + if (-not(Test-Path($userConfigFile))) {
vmware: + ~~~~~~~~~~~~~~~~~
vmware: + CategoryInfo : InvalidData: (:) [Test-Path], ParameterBindingVa
vmware: lidationException
vmware: + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,M
vmware: icrosoft.PowerShell.Commands.TestPathCommand
vmware:
vmware: Get-Content : Cannot bind argument to parameter 'Path' because it is null.
vmware: At C:\Chocolatey\chocolateyinstall\functions\Get-UserConfigValue.ps1:16 char:42
vmware: + $userConfig = [xml] (Get-Content $userConfigFile)
vmware: + ~~~~~~~~~~~~~~~
vmware: + CategoryInfo : InvalidData: (:) [Get-Content], ParameterBinding
vmware: ValidationException
vmware: + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,M
vmware: icrosoft.PowerShell.Commands.GetContentCommand
vmware:
vmware: Join-Path : Cannot bind argument to parameter 'Path' because it is null.
vmware: At C:\Chocolatey\chocolateyinstall\functions\Get-UserConfigValue.ps1:11 char:37
vmware: + $userConfigFile = Join-Path $env:USERPROFILE chocolatey.config
vmware: + ~~~~~~~~~~~~~~~~
vmware: + CategoryInfo : InvalidData: (:) [Join-Path], ParameterBindingVa
vmware: lidationException
vmware: + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,M
vmware: icrosoft.PowerShell.Commands.JoinPathCommand
vmware:
vmware: Test-Path : Cannot bind argument to parameter 'Path' because it is null.
vmware: At C:\Chocolatey\chocolateyinstall\functions\Get-UserConfigValue.ps1:13 char:27
vmware: + if (-not(Test-Path($userConfigFile))) {
vmware: + ~~~~~~~~~~~~~~~~~
vmware: + CategoryInfo : InvalidData: (:) [Test-Path], ParameterBindingVa
vmware: lidationException
vmware: + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,M
vmware: icrosoft.PowerShell.Commands.TestPathCommand
vmware:
vmware: Get-Content : Cannot bind argument to parameter 'Path' because it is null.
vmware: At C:\Chocolatey\chocolateyinstall\functions\Get-UserConfigValue.ps1:16 char:42
vmware: + $userConfig = [xml] (Get-Content $userConfigFile)
vmware: + ~~~~~~~~~~~~~~~
vmware: + CategoryInfo : InvalidData: (:) [Get-Content], ParameterBinding
vmware: ValidationException
vmware: + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,M
vmware: icrosoft.PowerShell.Commands.GetContentCommand
vmware:
vmware: ______ nodejs.install v0.10.20 ______
vmware: Join-Path : Cannot bind argument to parameter 'Path' because it is null.
vmware: At C:\Chocolatey\chocolateyinstall\functions\Delete-ExistingErrorLog.ps1:7 char
vmware: :28
vmware: + $chocTempDir = Join-Path $env:TEMP "chocolatey"
vmware: + ~~~~~~~~~
vmware: + CategoryInfo : InvalidData: (:) [Join-Path], ParameterBindingVa
vmware: lidationException
vmware: + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,M
vmware: icrosoft.PowerShell.Commands.JoinPathCommand
vmware:
vmware: Join-Path : Cannot bind argument to parameter 'Path' because it is null.
vmware: At C:\Chocolatey\chocolateyinstall\functions\Delete-ExistingErrorLog.ps1:8 char
vmware: :24
vmware: + $tempDir = Join-Path $chocTempDir "$packageName"
vmware: + ~~~~~~~~~~~~
vmware: + CategoryInfo : InvalidData: (:) [Join-Path], ParameterBindingVa
vmware: lidationException
vmware: + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,M
vmware: icrosoft.PowerShell.Commands.JoinPathCommand
vmware:
vmware: Join-Path : Cannot bind argument to parameter 'Path' because it is null.
vmware: At C:\Chocolatey\chocolateyinstall\functions\Delete-ExistingErrorLog.ps1:9 char
vmware: :27
vmware: + $failureLog = Join-Path $tempDir 'failure.log'
vmware: + ~~~~~~~~
vmware: + CategoryInfo : InvalidData: (:) [Join-Path], ParameterBindingVa
vmware: lidationException
vmware: + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,M
vmware: icrosoft.PowerShell.Commands.JoinPathCommand
vmware:
vmware: Join-Path : Cannot bind argument to parameter 'Path' because it is null.
vmware: At C:\Chocolatey\chocolateyinstall\helpers\functions\Write-ChocolateyFailure.ps
vmware: 1:7 char:28
vmware: + $chocTempDir = Join-Path $env:TEMP "chocolatey"
vmware: + ~~~~~~~~~
vmware: + CategoryInfo : InvalidData: (:) [Join-Path], ParameterBindingVa
vmware: lidationException
vmware: + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,M
vmware: icrosoft.PowerShell.Commands.JoinPathCommand
vmware:
vmware: Join-Path : Cannot bind argument to parameter 'Path' because it is null.
vmware: At C:\Chocolatey\chocolateyinstall\functions\Run-ChocolateyPS1.ps1:47 char:32
vmware: + $chocTempDir = Join-Path $env:TEMP "chocolatey"
vmware: + ~~~~~~~~~
vmware: + CategoryInfo : InvalidData: (:) [Join-Path], ParameterBindingVa
vmware: lidationException
vmware: + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,M
vmware: icrosoft.PowerShell.Commands.JoinPathCommand
vmware:
vmware: Join-Path : Cannot bind argument to parameter 'Path' because it is null.
vmware: At C:\Chocolatey\chocolateyinstall\functions\Run-ChocolateyPS1.ps1:48 char:28
vmware: + $tempDir = Join-Path $chocTempDir "$packageName"
vmware: + ~~~~~~~~~~~~
vmware: + CategoryInfo : InvalidData: (:) [Join-Path], ParameterBindingVa
vmware: lidationException
vmware: + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,M
vmware: icrosoft.PowerShell.Commands.JoinPathCommand
vmware:
vmware: Join-Path : Cannot bind argument to parameter 'Path' because it is null.
vmware: At C:\Chocolatey\chocolateyinstall\functions\Run-ChocolateyPS1.ps1:49 char:31
vmware: + $failureLog = Join-Path $tempDir 'failure.log'
vmware: + ~~~~~~~~
vmware: + CategoryInfo : InvalidData: (:) [Join-Path], ParameterBindingVa
vmware: lidationException
vmware: + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,M
vmware: icrosoft.PowerShell.Commands.JoinPathCommand
from packer-windows.
I believe Chocolatey is looking for TEMP as a user variable. The shell we are using over ssh doesn't expose this correctly although it's something I believe we can fix.
Regardless, try this as the first line of your script
set TEMP=C:\Windows\Temp
from packer-windows.
For the sake of some closure...
set /p PATH=<C:\Windows\Temp\PATH
set TEMP=C:\Windows\Temp
set USERPROFILE=C:\Users\vagrant
cinst Firefox
Setting both TEMP and USERPROFILE in your chocopacks script solves the immediate problem.
It's discouraging that these are not automatically assigned.
We can set TEMP from ~/.ssh/environment which is great, but setting the USERPROFILE variable from there isn't working at all, like it's blacklisted. It seems like a pretty ridiculous behavior.
from packer-windows.
I didn't follow up sooner, cause I felt kinda stupid. I added the set TEMP=C:\Windows\Temp to the script, but that didn't seem to help. And I suspected that it had to do with a userprofile, but I totally had no clue how to debug the scripts.
I added the USERPROFILE=C:\Users\vagrant and now cinst Firefox worked correctly but cinst nodejs.install still gives me an error.
I hope someone can tell me how to debug scripts or someway interactively run cmdline commands from outside the vm, through ssh.
from packer-windows.
@saberone This is why I would use Vagrant to test your scripts - once you have them sorted out, you can always come back and apply them to your Packer provisioner/s. The rationale for this is: you don't want to have to go through installing virtualization tools, installing Windows updates, etc every time you make a change to your script / every time you need to debug an issue.
Using Vagrant with a pre-built box (built using Packer) will short circuit all that time consuming work required to build the base box, allowing you to focus on getting your automation to work. Once it does work, you can either:
a) Let Vagrant build a box for you, derived from the base box built using Packer
b) Move your scripts to your Packer build, once you know they work, so they're baked into your base box
Hope that makes sense?
from packer-windows.
Yes makes sense! Thx for the tips
from packer-windows.
Related Issues (20)
- Internet Explorer can't open while User Account Control is turned off HOT 1
- Installation of Cygwin HOT 2
- Windows 10 still asking for region HOT 3
- Windows 2012 R2 in Waiting for SSH to become available... HOT 3
- Windows could not apply the unattend answer file's <DiskConfiguration> setting HOT 6
- vm-guest-tools.bat - Server 2016 issue HOT 4
- Disable welcome animation on Windows 8/10
- [question] Exclude Windows Update Patches KB's during update
- Packer hangs at : ==> vmware-iso: Waiting for SSH to become available... HOT 3
- VMWare tools installation hangs HOT 1
- debloat-windows.ps1 fails
- Packer(version1.3.2) running from AWS CodeBuild, Stops abruptly while execution PS script
- Step "StepProvision" failed
- Windows 7 iso is no longer available HOT 4
- Avoid using SourceForge tools to prevent potentially unwanted programms from being installed
- Multiple insecure HTTP download links HOT 3
- Windows Server 2019 win-updates.ps1 issue HOT 1
- Windows 10 "Waiting for WinRM to become available" HOT 1
- build stops at or after UltraDefrag HOT 1
- looks like a password was leaked as part of the openssh.ps1 script
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from packer-windows.