gpt4 book ai didi

windows - Hashicorp Packer 不会在 Windows 主机上执行 packer-provisioner-shell

转载 作者:可可西里 更新时间:2023-11-01 09:37:06 26 4
gpt4 key购买 nike

这是我的第一个问题。我尝试遵循所有准则。

我正在尝试使用 Packer 创建 Debian 8 的 Vagrant 镜像。如果我运行仅使用“builders”模板的 packer 构建,它将成功执行并生成 Virtualbox 镜像。当我尝试添加“供应商”和/或“后处理器”模板时,我开始出错。该错误在大约 10 秒内发生。它不会运行生成器。错误信息是:

ui error: Failed to initialize build 'virtualbox-iso': error initializing provisioner 'shell': dial tcp 127.0.0.1:10000: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

这几天我一直在研究这个问题。我有:

  • 在 Google 中搜索错误文本
  • 通读了一些 Packer 源代码(以为我不熟悉 Go)
  • 使用从 Packer.io 全新下载的内容重新安装了 Packer
  • 确保文件未被阻止
  • 以我的默认用户和管理员身份执行
  • 使用 Git Bash 代替 cmd.exe
  • 从 Powershell 执行
  • 使用了 Atlas 提供的 atlas-packer-vagrant-tutorial。它将建立在 Atlas 之上,但不在本地。

我的 Packer 模板文件:

{
"provisioners": [{
"type": "shell",
"scripts": [
"scripts/vagrant.sh"
],
"override": {
"virtualbox-iso": {
"execute_command": "echo 'vagrant' | sudo -S bash '{{.Path}}'"
}
}
}],
"builders": [{
"type": "virtualbox-iso",
"guest_os_type": "Debian_64",
"iso_url": "http://cdimage.debian.org/debian-cd/8.2.0/amd64/iso-cd/debian-8.2.0-amd64-CD-1.iso",
"iso_checksum": "234bd43d85974299d501f370ac3e7592b98832d98f82be3aff190ff3af831f8cd7574a75f4c9b36c347f138e82ccb40ff3746a4c94e7d59e4ee711e0c96dbf1d",
"iso_checksum_type": "sha512",
"ssh_username": "vagrant",
"ssh_password": "vagrant",
"ssh_wait_timeout": "120m",
"shutdown_command": "echo 'vagrant' | sudo -S shutdown -h now",
"disk_size": "20480",
"http_directory": "http",
"boot_command": [
"<esc><wait>",
"auto url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg ",
"<enter>"
],
"vboxmanage": [
["modifyvm", "{{.Name}}", "--memory", "4096"],
["modifyvm", "{{.Name}}", "--cpus", "2"]
]
}],
"post-processors": ["vagrant"]
}

我没有足够的声誉来添加额外的链接。 TCP 查看输出:

packer-provisioner-shell.exe        3940    TCP 127.0.0.1   10000   0.0.0.0 0       LISTENING
packer-builder-virtualbox-iso.exe 11284 TCP 127.0.0.1 10000 127.0.0.1 49568 ESTABLISHED
packer.exe 12180 TCP 127.0.0.1 49568 127.0.0.1 10000 ESTABLISHED
packer.exe 12180 TCP 127.0.0.1 49571 127.0.0.1 10000 SYN_SENT

系统信息:

  • Windows 7 专业版 SP1(64 位)
  • 封隔器 0.8.6

我的完整代码在 Github 上 repo

我的完整错误登录在此 Gist

感谢您提供的任何帮助。

最佳答案

我在 Windows 主机上有一个与加壳器类似的问题,但我可以正确构建(在 vagrant 中配置错误都是一样的)。

但是您可以使用另一个为我正确运行的项目打包器或将其与您的项目进行比较。也许找到解决或理解其他概念的方法可以帮助您:packer ubuntu project

关于windows - Hashicorp Packer 不会在 Windows 主机上执行 packer-provisioner-shell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34486582/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com