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/
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With