我是 Chef/Packer 的新手,如果这是一个新手问题,我很抱歉,基本上我试图让 Packer 使用我的本地机器来构建图像并执行 shell 脚本。以下是我的 packer-build.json
{
"builders": [
{
"type": "file",
"name": "example",
"target": "./test_artifact.txt",
"content": "example content"
}
],
"provisioners": [
{
"type": "chef-solo",
"cookbook_paths": ["/Users/bakthak/code/nc_deployment/chef-repo/cookbooks"],
"staging_directory": "/Users/bakthak",
"execute_command": "sh /Users/bakthak/check.sh"
}
]
}
使用此文件运行构建会产生输出
==> example: Provisioning with chef-solo
example: Installing Chef...
example: Creating directory: /Users/bakthak
example: Creating directory: /Users/bakthak/cookbooks-0
example: Creating configuration file 'solo.rb'
example: Creating JSON attribute file
example: Executing Chef: sh /Users/bakthak/check.sh
Build 'example' finished.
我对此有几个问题:
- Packer 是否使用我的本地机器安装 Chef 并构建映像?
- 看起来 shell 脚本
sh /Users/bakthak/check.sh
没有执行,因为该脚本在打包器构建完成后不存在的目录中创建了一堆文件。
谢谢您的帮助 :)