gpt4 book ai didi

packer - 如何将 Packer.io ISO_URL 作为命令行参数传递

转载 作者:行者123 更新时间:2023-12-04 12:48:47 25 4
gpt4 key购买 nike

我想将 ISO_URL 作为命令行参数传递。我试着按照 https://www.packer.io/docs/templates/user-variables.html 上的一个例子

我的变量部分看起来像

"variables": {
"build_version": "1.0.0",
"iso_checksum_type":"md5",
"iso_checksum":"453312bf56fc45669fec5ebc0f025ac7",
"iso_url":"c:\fake.iso"
}

变量引用

   ...
"iso_checksum": "{{user `iso_checksum`}}",
"iso_checksum_type":"{{user `iso_checksum_type`}}",
"iso_url": "{{user `iso_url`}}",
...

构建命令是

packer build -var 'iso_url=c:\debian.iso' packerio.json

但是,iso_url 没有被覆盖,加壳程序正在尝试下载 fake.iso

为什么?

准确的结果是

virtualbox-iso output will be in this color.

==> virtualbox-iso: Downloading or copying Guest additions
virtualbox-iso: Downloading or copying: file:///C:/Program%20Files/Oracle/VirtualBox/VBoxGuestAdditions.iso
==> virtualbox-iso: Downloading or copying ISO
virtualbox-iso: Downloading or copying: file:///c:/fake.iso
virtualbox-iso: Error downloading: GetFileAttributesEx c:/fake.iso: The system cannot find the file specified.
==> virtualbox-iso: ISO download failed.
Build 'virtualbox-iso' errored: ISO download failed.

==> Some builds didn't complete successfully and had errors:
--> virtualbox-iso: ISO download failed.

==> Builds finished but no artifacts were created.

最佳答案

解决方案是将单引号替换为双引号或省略引号。

packer build -var "iso_url=c:\debian.iso" packerio.json

packer build -var iso_url=c:\debian.iso packerio.json

另外,相对路径也可以

packer build -var iso_url=\subfolder_name\debian.iso packerio.json

感谢@RickardvonEssen 为我指明了正确的方向。

关于packer - 如何将 Packer.io ISO_URL 作为命令行参数传递,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41862494/

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