Packer: Unknown "User (you) cancelled the installation" errors

Created on 18 Apr 2018  ·  4Comments  ·  Source: hashicorp/packer

Greetings,

I'm having issues with Packer installing Chocolately packages. I've also opened an equivalent issue in the Chocolately repository (https://github.com/chocolatey/chocolatey-coreteampackages/issues/1002), but I also wanted to open an issue here because I think it's more Packer related. The reason I think so is because running the problematic choco command via a GUI in Windows Server 2012 R2 actually works. It's only when I run the command in Packer that I get a failed build.

In short, when running the command:

choco install -y dotnetcore-runtime

Packer throws a User (you) cancelled the installation error, and then spits out the following Chocolately related messages:

amazon-ebs: Failures
amazon-ebs:  - kb3035131 (exited 5) - Error while running 'C:\ProgramData\chocolatey\lib\KB3035131\Tools\ChocolateyInstall.ps1'.
amazon-ebs:  See log for details.
amazon-ebs: Installing KB3035131...
amazon-ebs: WARNING: User (you) cancelled the installation.
amazon-ebs: WARNING: Update KB3035131 installation failed (exit code 5).
amazon-ebs: WARNING: More details may be found in the installation log (C:\Users\Administrator\AppData\Local\Temp\chocolatey\KB3035131.Install.evt) or the system CBS log (C:\Windows\Logs\CBS\CBS.log).
amazon-ebs: ERROR: Update KB3035131 installation failed (exit code 5).
amazon-ebs: The install of kb3035131 was NOT successful.
amazon-ebs: Error while running 'C:\ProgramData\chocolatey\lib\KB3035131\Tools\ChocolateyInstall.ps1'.
amazon-ebs:  See log for details.

Packer version: 1.2.2
Host platform: AWS

Example Packer template, debug log, and AWS bootstrap config are all included in this gist: https://gist.github.com/sc250024/fede4468306417c9cdee5e2702a6cb09

upstream-bug

Most helpful comment

I have also been experiencing this. Windows server 2016 core and 2016 gui work fine, but 2012 exits with exit code 5.

The reason why this fails on some and not others is because the chocolatey package depends on windows update KB2919442 which you can't install without elevated credentials.

    {
      "type": "powershell",
      "inline": ["choco install dotnetfx --verison 4.7.2 --verbose -y"],
      "valid_exit_codes": [0,3010],
      "elevated_user": "vagrant",
      "elevated_password": "vagrant"
    },
    {
      "type": "powershell",
      "inline": ["choco install dotnet4.7.2 --verbose -y"],
      "valid_exit_codes": [0,3010],
      "elevated_user": "vagrant",
      "elevated_password": "vagrant"
    },

All 4 comments

This looks like an issue that has been seen before for the .Net Chocolatey package - see HERE. Although it was ultimately decided this issue was raised in the wrong place (it should have been raised with the Chocolatey package maintainers HERE) the discussion that follows seems to suggest that it's the Chocolatey package that's causing the issue.

@DanHam Thanks for the reply. For anyone experiencing this, I found a solution:

    "provisioners": [
        {
            "type": "powershell",
            "elevated_user": "Administrator",
            "elevated_password": "{{ .WinRMPassword }}",
            "inline": [
                "Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))",
                "choco install -y dotnetcore-runtime"
            ]
        }
    ]

Simply run the commands with the elevated_ tags I have above, and that does the trick. Seems fairly obvious now, but definitely wasn't at the time 😄

I have also been experiencing this. Windows server 2016 core and 2016 gui work fine, but 2012 exits with exit code 5.

The reason why this fails on some and not others is because the chocolatey package depends on windows update KB2919442 which you can't install without elevated credentials.

    {
      "type": "powershell",
      "inline": ["choco install dotnetfx --verison 4.7.2 --verbose -y"],
      "valid_exit_codes": [0,3010],
      "elevated_user": "vagrant",
      "elevated_password": "vagrant"
    },
    {
      "type": "powershell",
      "inline": ["choco install dotnet4.7.2 --verbose -y"],
      "valid_exit_codes": [0,3010],
      "elevated_user": "vagrant",
      "elevated_password": "vagrant"
    },

I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings