gentoo之为什么 shell-local 不会下载 stage3

zhujiabin 阅读:49 2025-05-04 20:05:19 评论:0

我正在处理位于 here 的模板.在提供部分我有:

"provisioners": [ 
  { 
    "type": "shell-local", 
    "command": "wget http://distfiles.gentoo.org/releases/amd64/autobuilds/{{user `stage3-date`}}/stage3-amd64-{{user `stage3-date`}}.tar.bz2" 
  }, 
  { 
    "type": "file", 
    "source": "stage3-amd64-{{user `stage3-date`}}.tar.bz2", 
    "destination": "/root" 
  }, 
  { 
    "destination": "/root", 
    "source": "scripts/", 
    "type": "file" 
  }, 
  { 
    "environment_vars": [ 
      "STAGE3={{user `stage3-date`}}" 
    ], 
    "type": "shell", 
    "inline": ["cd /root", "chmod u+x provision.sh", "./provision.sh"] 
  } 
] 

我的目标是在需要时下载 stage3,执行 md5 检查,然后将其移动到虚拟机上的/root,但这并没有发生。 (对于那些不熟悉 gentoo 的人来说,这是需要解压到 chrooted hd 的实际安装文件)。这是输出。

john@g1 gentoo-packer $ packer build -debug gentoo64.json  
Debug mode enabled. Builds will not be parallelized. 
virtualbox-iso output will be in this color. 
 
1 error(s) occurred: 
 
* Bad source 'stage3-amd64-20150924.tar.bz2': stat stage3-amd64-20150924.tar.bz2: no such file or directory 

看起来 packer 正试图在“shell-local”之前运行"file"配置程序。由于 packer 不按照 provisioners 数组的顺序进行,有什么方法可以在运行 provisioner 时强制执行顺序?

注1:

我很确定line 58在文件提供者中导致我所有的问题。这些文件是在加壳器启动时检查的,而不是在供应器运行时检查的。由于文件尚未下载,因此失败。

请您参考如下方法:

这不是一个答案,更多潜在的指导

来自 doc它说

For each of the definitions, Packer will run the provisioner for each of the configured builds. The provisioners will be run in the order they are defined within the template.

您确定该文件可用吗?你能单独尝试 shell-local provisioner 并确保文件被下载吗

您还可以尝试使用 wget 上的 -P 选项强制文件的目标位置,以确保它保存在有效目录中,然后在那里重新读取表单。


标签:Shell
声明

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

关注我们

一个IT知识分享的公众号