]> git.openstreetmap.org Git - chef.git/commitdiff
Only configure unattended-upgrades once it is installed
authorTom Hughes <tom@compton.nu>
Thu, 25 Aug 2016 19:38:06 +0000 (20:38 +0100)
committerTom Hughes <tom@compton.nu>
Thu, 25 Aug 2016 19:38:06 +0000 (20:38 +0100)
cookbooks/apt/recipes/default.rb

index 4243d565d1e2045839b8018802c0b7a689f2706a..cc6e470693c5a59c01b1812ce7dca8c8ae8b02d3 100644 (file)
@@ -130,17 +130,19 @@ end
 
 package "unattended-upgrades"
 
-auto_upgrades = if node[:apt][:unattended_upgrades][:enable]
-                  IO.read("/usr/share/unattended-upgrades/20auto-upgrades")
-                else
-                  IO.read("/usr/share/unattended-upgrades/20auto-upgrades-disabled")
-                end
-
-file "/etc/apt/apt.conf.d/20auto-upgrades" do
-  user "root"
-  group "root"
-  mode 0o644
-  content auto_upgrades
+if Dir.exist?("/usr/share/unattended-upgrades")
+  auto_upgrades = if node[:apt][:unattended_upgrades][:enable]
+                    IO.read("/usr/share/unattended-upgrades/20auto-upgrades")
+                  else
+                    IO.read("/usr/share/unattended-upgrades/20auto-upgrades-disabled")
+                  end
+
+  file "/etc/apt/apt.conf.d/20auto-upgrades" do
+    user "root"
+    group "root"
+    mode 0o644
+    content auto_upgrades
+  end
 end
 
 template "/etc/apt/apt.conf.d/60chef" do