sous-chefs / apt

Development repository for the apt cookbook
https://supermarket.chef.io/cookbooks/apt
Apache License 2.0
201 stars 266 forks source link

Cloning Resource #170

Closed jcputter closed 7 years ago

jcputter commented 8 years ago

WARN: Cloning resource attributes for file[/etc/apt/preferences.d/my_packages.pref] from prior resource (CHEF-3694)

I'm using the following

apt_preference 'my_packages' do
  glob         '*'
  pin          'repo.mypackages.com'
  pin_priority '700'
end
jcputter commented 8 years ago

anyone?

haimgel commented 8 years ago

I'm not 100% sure, but I think the logic is not 100% correct in the preferences resource, e.g. it should be changed like this:

--- a/cookbooks/apt/providers/preference.rb
+++ b/cookbooks/apt/providers/preference.rb
@@ -54,8 +54,7 @@ action :add do
     if ::File.exist?("/etc/apt/preferences.d/#{new_resource.name}.pref")
       Chef::Log.warn "Replacing #{new_resource.name}.pref with #{name}.pref in /etc/apt/preferences.d/"
     end
-    only_if { name != new_resource.name }
-  end
+  end if name != new_resource.name

   file "/etc/apt/preferences.d/#{new_resource.name}" do
     action :delete

Otherwise we get the resource cloning, as the "Replacing xx.pref" log warning gets executed every time.

EugenMayer commented 7 years ago

did yet not really get released, right?

tas50 commented 7 years ago

5.0.1 has been released