Use archive.ubuntu.com if we don't know the country
[chef.git] / cookbooks / apt / recipes / default.rb
index d5e002d61a133151165dbd302b667c09cd280ceb..4243d565d1e2045839b8018802c0b7a689f2706a 100644 (file)
@@ -29,11 +29,18 @@ execute "apt-update" do
   command "/usr/bin/apt-get update"
 end
 
+archive_host = if node[:country]
+                 "#{node[:country]}.archive.ubuntu.com"
+               else
+                 "archive.ubuntu.com"
+               end
+
 template "/etc/apt/sources.list" do
   source "sources.list.erb"
   owner "root"
   group "root"
   mode 0o644
+  variables :archive_host => archive_host, :codename => node[:lsb][:codename]
   notifies :run, "execute[apt-update]", :immediately
 end