Azure Windows Packer生成通过Chocolately安装Chefdk挂起

时间:2019-05-20 21:18:44

标签: windows azure chef packer chocolatey

运行packer build时,它会挂在chefdk下载上,对于python也是一样,但是它将安装多个其他应用程序。有人知道为什么吗?

最初全部由单个脚本运行,即安装choco然后安装应用程序

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

我已经尝试将它们分离为内联代码,以解决仍然遇到相同问题的所有问题。

为了确保这一点,我还手动运行了脚本,并且一切正常(没有提示回答的问题。)

我曾经在添加“ winrm_password”之后在预配器中调用它,但是它说密码错误!

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'

打包程序供应商为:

  "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"
  }
]

任何想法如何解决?在Google上似乎没有太多关于Packer的信息,这表明它可以正常工作!

1 个答案:

答案 0 :(得分:0)

您是否尝试过使用Powershell配置器通过Chef文档安装https://docs.chef.io/install_omnibus.html

在最底部: . { iwr -useb https://omnitruck.chef.io/install.ps1 } | iex; install -channel current -project chefdk

包装工看起来像:

  "provisioners": [{
      "type": "powershell",
      "inline": ". { iwr -useb https://omnitruck.chef.io/install.ps1 } | iex; install -channel current -project chefdk"
    }]