简体   繁体   English

带有主厨-单人配置功能的Packer无效

[英]Packer with chef-solo provisioning does nothing

I'm starting up with Packer using chef-solo to provision. 我从Packer开始,使用Chef-solo进行配置。 I have a very simple recipe (default.rb) that contains the lines below: 我有一个非常简单的食谱(default.rb),其中包含以下几行:

package "git"
package "ruby"
package "rubygems"

I was able to provision an image using Vagrant with this successfully. 我能够成功地使用Vagrant设置映像。 I'm now trying to move this provision step to Packer but when I execute packer build it doesn't seem to run the recipe. 我现在正在尝试将此设置步骤移至Packer,但是当我执行Packer packer build它似乎没有运行该配方。

virtualbox-iso: Running handlers complete
virtualbox-iso: Chef Client finished, 0/0 resources updated in 1.818437359 seconds

My Packer template's provision section is: 我的Packer模板的设置部分为:

{
   "type": "chef-solo",
   "cookbook_paths": ["/cookbooks"]
}

My second part to this question (I'm assuming it's going to be related) is what is the run_list configuration option? 关于这个问题的第二部分(我假设这将是相关的)是run_list配置选项是什么?

The Packer documentation says it goes in the same file, is called run_list, and by default is empty. Packer文档说它在同一个文件中,称为run_list,默认情况下为空。 So you should give the name of your cookbook as a single-element string array, in a param called run_list. 因此,您应该在名为run_list的参数中以单元素字符串数组的形式给出食谱的名称。

For beginners like myself who are looking for an answer, I addressed this by adding a run_list like the following: 对于正在寻找答案的像我这样的初学者,我通过添加以下run_list来解决此问题:

"run_list": ["git::default"]

'git' is the name in the metadata.rb file and 'default' is the filename or recipe (if my terminology is correct). “ git”是metadata.rb文件中的名称,“默认”是文件名或配方(如果我的术语正确)。 My cookbook directory structure is as follows: 我的菜谱目录结构如下:

~/Projects/Packer-Templates/Cookbooks $ find .
.
./ruby-environment
./ruby-environment/metadata.rb
./ruby-environment/recipes
./ruby-environment/recipes/default.rb

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM