]> git.openstreetmap.org Git - chef.git/blob - cookbooks/apt/recipes/default.rb
apt: use apt_preference to pin cciss-vol-status
[chef.git] / cookbooks / apt / recipes / default.rb
1 #
2 # Cookbook:: apt
3 # Recipe:: default
4 #
5 # Copyright:: 2010, Tom Hughes
6 #
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
10 #
11 #     https://www.apache.org/licenses/LICENSE-2.0
12 #
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 #
19
20 package %w[
21   apt
22   apt-transport-https
23   gnupg
24   update-notifier-common
25 ]
26
27 file "/etc/motd.tail" do
28   action :delete
29 end
30
31 # FIXME: cleanup old package pin method for cciss-vol-status
32 file "/etc/apt/preferences.d/99-chef" do
33   action :delete
34 end
35
36 apt_preference "cciss-vol-status" do
37   pin          "origin *.ubuntu.com"
38   pin_priority "1100"
39 end
40
41 apt_update "/etc/apt/sources.list" do
42   action :nothing
43 end
44
45 if intel?
46   archive_host = if node[:country]
47                    "#{node[:country]}.archive.ubuntu.com"
48                  else
49                    "archive.ubuntu.com"
50                  end
51   archive_security_host = "security.ubuntu.com"
52   archive_distro = "ubuntu"
53 else
54   archive_host = "ports.ubuntu.com"
55   archive_security_host = archive_host
56   archive_distro = "ubuntu-ports"
57 end
58
59 template "/etc/apt/sources.list" do
60   source "sources.list.erb"
61   owner "root"
62   group "root"
63   mode "644"
64   variables :archive_host => archive_host, :archive_security_host => archive_security_host, :archive_distro => archive_distro, :codename => node[:lsb][:codename]
65   notifies :update, "apt_update[/etc/apt/sources.list]", :immediately
66 end
67
68 apt_repository "openstreetmap" do
69   uri "ppa:osmadmins/ppa"
70 end
71
72 package "unattended-upgrades"
73
74 if Dir.exist?("/usr/share/unattended-upgrades")
75   auto_upgrades = if node[:apt][:unattended_upgrades][:enable]
76                     IO.read("/usr/share/unattended-upgrades/20auto-upgrades")
77                   else
78                     IO.read("/usr/share/unattended-upgrades/20auto-upgrades-disabled")
79                   end
80
81   file "/etc/apt/apt.conf.d/20auto-upgrades" do
82     user "root"
83     group "root"
84     mode "644"
85     content auto_upgrades
86   end
87 end
88
89 template "/etc/apt/apt.conf.d/60chef" do
90   source "apt.conf.erb"
91   owner "root"
92   group "root"
93   mode "644"
94 end