简体   繁体   English

如何在循环中停止资源克隆以获取厨师食谱?

[英]How to stop resource cloning in a loop for a chef recipe?

I have a chef recipe that installs packages in a loop: 我有一个厨师食谱,可以在一个循环中安装包:

pkgs.each do |pkg|
  yum_package "tools" do
    package_name pkg
    action :install
  end
end

This recipe is however throwing the following error: 但是这个方法会引发以下错误:

[2014-05-22T08:26:13-04:00] WARN: Cloning resource attributes for yum_package[tools] from prior resource (CHEF-3694)
[2014-05-22T08:26:13-04:00] WARN: Previous yum_package[tools]: /var/chef/cache/cookbooks/tools/recipes/default.rb:9:in `block in from_file'

Eventually, this feature is going to be removed . 最终, 此功能将被删除 So, I need to find a way to properly loop in a chef recipe without throwing this warning; 所以,我需要找到一种方法来正确地循环一个厨师食谱而不抛出这个警告; I've had no luck thus far trying to figure this out; 到目前为止,我没有运气试图解决这个问题; I'm wondering if anyone else has a solution? 我想知道是否有其他人有解决方案?

package_name is the name attribute. package_name name属性。 Just do this: 这样做:

ops_pkgs.each do |pkg|
  yum_package pkg
end

You do not even need to block because action :install is the default action. 您甚至不需要阻止因为action :install是默认操作。

I made the resource in the loop unique to fix the issue: 我在循环中使资源独一无二,以解决问题:

ops_pkgs.each do |pkg|
  yum_package "tools #{pkg}" do
    package_name pkg
    action :install
  end
end

Old question I know, but I wanted to at least get some experts' opinions on this. 老问题我知道,但我想至少得到一些专家的意见。 Maybe it is a better solution to use the cookbook which acknowledges that you probably do want it to clone and merge and not throw a warning about it: 也许这是一个更好的解决方案要使用的承认, 可能希望它复制和合并,而不是抛出一个警告,关于它的食谱:

http://scottwb.com/blog/2014/01/24/defeating-the-infamous-chef-3694-warning/ http://scottwb.com/blog/2014/01/24/defeating-the-infamous-chef-3694-warning/

This only works for the action, but it could be extended to others. 这仅适用于该操作,但可以扩展到其他操作。

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

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