Giter Club home page Giter Club logo

Comments (8)

dylanmei avatar dylanmei commented on July 30, 2024

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.

joefitzgerald avatar joefitzgerald commented on July 30, 2024

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.

saberone avatar saberone commented on July 30, 2024

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.

dylanmei avatar dylanmei commented on July 30, 2024

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.

dylanmei avatar dylanmei commented on July 30, 2024

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.

saberone avatar saberone commented on July 30, 2024

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.

joefitzgerald avatar joefitzgerald commented on July 30, 2024

@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.

saberone avatar saberone commented on July 30, 2024

Yes makes sense! Thx for the tips

from packer-windows.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.