0

When running packer build, it hangs on the chefdk download, the same things happens for python, but it will install multiple other applications. does anyone know why?

Originally had it all run from a single script ie install choco then install apps

if (!(Get-Package -Name *choco*))
{
    Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
}
choco install visualstudiocode -y
choco install chefdk -y

I have tried separating them out into inline code for everything i still get the same issue.

Just to make sure, i have also ran the script manually and everything works (there are no prompts for responses.)

Ive played with adding "winrm_password" then calling that in the provisioner but it says the password is wrong!?

Output from Packer:

    azure-arm: vscode v1.34.0 [Approved]
    azure-arm: vscode package files install completed. Performing other installation steps.
    azure-arm: Merge Tasks: !runCode, desktopicon, quicklaunchicon, addcontextmenufiles, addcontextmenufolders, addtopath
    azure-arm: Downloading vscode 64 bit
    azure-arm:   from 'https://az764295.vo.msecnd.net/stable/a622c65b2c713c890fcf4fbf07cf34049d5fe758/VSCodeSetup-x64-1.34.0.exe'
Progress: 100% - Completed download of C:\Users\packer\AppData\Local\Temp\chocolatey\vscode\1.34.0\VSCodeSetup-x64-1.34.0.exe (47.85 MB).
    azure-arm: Download of VSCodeSetup-x64-1.34.0.exe (47.85 MB) completed.
    azure-arm: Hashes match.
    azure-arm: Installing vscode...
    azure-arm: vscode has been installed.
    azure-arm:   vscode can be automatically uninstalled.
    azure-arm: Environment Vars (like PATH) have changed. Close/reopen your shell to
    azure-arm:  see the changes (or in powershell/cmd.exe just type `refreshenv`).
    azure-arm:  The install of vscode was successful.
    azure-arm:   Software installed to 'C:\Program Files\Microsoft VS Code\'
    azure-arm: VisualStudioCode v1.23.1.20180730 [Approved]
    azure-arm: visualstudiocode package files install completed. Performing other installation steps.
    azure-arm: This package is deprecated due to name change to vscode
    azure-arm:  The install of visualstudiocode was successful.
    azure-arm:   Software install location not explicitly set, could be in package or
    azure-arm:   default install location if installer.
    azure-arm: Chocolatey installed 4/4 packages.
    azure-arm:  See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
    azure-arm: Chocolatey v0.10.13
    azure-arm: Installing the following packages:
    azure-arm: chefdk
    azure-arm: By installing you accept licenses for the packages.
Progress: Downloading chefdk 3.7.23... 100%
    azure-arm: chefdk v3.7.23 [Approved]
    azure-arm: chefdk package files install completed. Performing other installation steps.
    azure-arm: Downloading chefdk 64 bit
    azure-arm:   from 'https://packages.chef.io/stable/windows/2012r2/chefdk-3.7.23-1-x64.msi'

packer provisioners is:

  "provisioners": [
    {
      "type": "powershell",
      "script": "choco.ps1"
  },
    {
    "type": "powershell",
    "inline": [
      "choco install vscode -y",
      "choco install chefdk -y",
      "& $env:SystemRoot\\System32\\Sysprep\\Sysprep.exe /oobe /generalize /quiet /quit",
      "while($true) { $imageState = Get-ItemProperty HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Setup\\State | Select ImageState; if($imageState.ImageState -ne 'IMAGE_STATE_GENERALIZE_RESEAL_TO_OOBE') { Write-Output $imageState.ImageState; Start-Sleep -s 10  } else { break } }"

    ],
    "pause_before": "1m"
  }
]

Any ideas how to fix? There doesnt seem to much about on google for packer, which suggests it just works!

Staggerlee011
  • 847
  • 2
  • 13
  • 23

1 Answers1

0

Have you tried using the powershell provisioner to install the chefdk via the chef docs: https://docs.chef.io/install_omnibus.html

At the very bottom: . { iwr -useb https://omnitruck.chef.io/install.ps1 } | iex; install -channel current -project chefdk

The packer piece would look like:

  "provisioners": [{
      "type": "powershell",
      "inline": ". { iwr -useb https://omnitruck.chef.io/install.ps1 } | iex; install -channel current -project chefdk"
    }]
devopsdina
  • 54
  • 3
  • Hi devopsdina, thanks for a work around! at least gets me rolling.. Still very interested to know why it does it though as it happens on multiple installs (while multiple work!) – Staggerlee011 May 23 '19 at 06:51