Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

chef resource cloning - what is it?

Tags:

chef-infra

I am trying to get more information on what chef resource cloning exactly is. I see them during my chef-client run but don’t know what they mean.

I’ve seen this blog below on resource cloning but I still can’t make sense of what it does. Does anyone have further information on this topic? Can’t find much else using google.

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

like image 718
user3440013 Avatar asked Mar 27 '14 02:03

user3440013


Video Answer


2 Answers

chef-client will merge resource definitions by their type and name (service[apache2] in your example). If you're working on wrapper cookbook check this great article: http://www.getchef.com/blog/2013/12/03/doing-wrapper-cookbooks-right from Julian Dunn.

Anyway, you can modify previously defined resources. In your case:

resources('service[apache2]').action [:enable, :start]

This will modify already defined resource service[apache2] and hide resource cloning warnings.

like image 66
Gleb M Borisov Avatar answered Oct 09 '22 23:10

Gleb M Borisov


Deprecation: Resource Cloning (CHEF-3694)

Chef allows resources to be created with duplicate names, rather than treating that as an error. This means that several cookbooks can request the same package be installed, without needing to carefully create unique names. This is problematic because having multiple resources named the same makes it impossible to safely deliver notifications to the right resource.

The behaviour in Chef 12 and earlier, which is now deprecated, is that we will try to clone the existing resource, and then apply any properties from the new resource. For example:

file "/etc/my_file" do
  owner "ken"
end

file "/etc/my_file" do
  mode "0755"
end

will result in the second instance having the following properties:

file "/etc/my_file" do
  owner "ken"
  mode "0755"
end

Resource cloning was deprecated in Chef 10.18.0 and will be removed in Chef 13.

like image 28
notapatch Avatar answered Oct 09 '22 23:10

notapatch