警告:克隆先前资源的资源属性

时间:2017-05-10 15:54:49

标签: rspec chef

我有以下食谱代码

# change permissions and group
execute 'set group' do
  command 'sudo chgrp -R tomcat /opt/tomcat/conf'
end

%w(/opt/tomcat/conf /opt/tomcat/conf/*).each do |tomcat_directory|
  execute 'set directory permissions' do
    command 'sudo chmod g+rwx ' + tomcat_directory
  end
end

当我运行chef exec rspec --color时,我看到所有测试都通过但是还有一个警告

[2017-05-10T21:12:36+05:30] WARN: Cloning resource attributes for execute[set directory permissions] from prior resource
Previous execute[set directory permissions]: C:/Users/AASJD~1/AppData/Local/Temp/chefspec20170510-14248-1faza0file_cache_path/cookbooks/tomcat/recipes/installtomcat.rb:25:in `block in from_file'
Current  execute[set directory permissions]:/Users/AASJD~1/AppData/Local/Temp/chefspec20170510-14248-1faza0file_cache_path/cookbooks/tomcat/recipes/installtomcat.rb:25:in `block in from_file' 
(CHEF-3694)C:/Users/AASJD~1/AppData/Local/Temp/chefspec20170510-14248-1faza0file_cache_path/cookbooks/tomcat/recipes/installtomcat.rb:25:in `block in from_file'.
Please see https://docs.chef.io/deprecations_resource_cloning.html for further details and information on how to correct this problem. at C:/opscode/chefdk/embedded/lib/ruby/gems/2.3.0/gems/chef-12.19.36-universal-mingw32/lib/chef/event_dispatch/dispatcher.rb:43:in `call'

https://docs.chef.io/deprecations_resource_cloning.html根据此链接,资源不应具有相同的名称,或者目标不应相同,但在这种情况下不是这样。那为什么会出现这个错误?

1 个答案:

答案 0 :(得分:0)

这是因为数组循环。以下代码修复了问题

%w(/opt/tomcat/conf /opt/tomcat/conf/*).each do |tomcat_directory|
  execute 'sudo chmod g+rwx ' + tomcat_directory
end