]> git.openstreetmap.org Git - chef.git/blob - cookbooks/apt/recipes/default.rb
4282ba107687b0d012c00e5032add03915700a51
[chef.git] / cookbooks / apt / recipes / default.rb
1 #
2 # Cookbook Name:: 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   update-notifier-common
24 ]
25
26 if node[:lsb][:release].to_f < 18.04
27   package "gnupg-curl"
28 end
29
30 file "/etc/motd.tail" do
31   action :delete
32 end
33
34 apt_update "/etc/apt/sources.list" do
35   action :nothing
36 end
37
38 archive_host = if node[:country]
39                  "#{node[:country]}.archive.ubuntu.com"
40                else
41                  "archive.ubuntu.com"
42                end
43
44 template "/etc/apt/sources.list" do
45   source "sources.list.erb"
46   owner "root"
47   group "root"
48   mode 0o644
49   variables :archive_host => archive_host, :codename => node[:lsb][:codename]
50   notifies :update, "apt_update[/etc/apt/sources.list]", :immediately
51 end
52
53 repository_actions = Hash.new do |_, repository|
54   node[:apt][:sources].include?(repository) ? :add : :remove
55 end
56
57 apt_repository "brightbox-ruby-ng" do
58   action repository_actions["brightbox-ruby-ng"]
59   uri "ppa:brightbox/ruby-ng"
60 end
61
62 apt_repository "ubuntugis-stable" do
63   action repository_actions["ubuntugis-stable"]
64   uri "ppa:ubuntugis/ppa"
65 end
66
67 apt_repository "ubuntugis-unstable" do
68   action repository_actions["ubuntugis-unstable"]
69   uri "ppa:ubuntugis/ubuntugis-unstable"
70 end
71
72 apt_repository "openstreetmap" do
73   action repository_actions["openstreetmap"]
74   uri "ppa:osmadmins/ppa"
75 end
76
77 apt_repository "squid2" do
78   action repository_actions["squid2"]
79   uri "ppa:osmadmins/squid2"
80 end
81
82 apt_repository "squid3" do
83   action repository_actions["squid3"]
84   uri "ppa:osmadmins/squid3"
85 end
86
87 apt_repository "management-component-pack" do
88   action repository_actions["management-component-pack"]
89   uri "https://downloads.linux.hpe.com/SDR/repo/mcp"
90   if node[:lsb][:release].to_f >= 16.04
91     distribution "xenial/current"
92   else
93     distribution "#{node[:lsb][:codename]}/current"
94   end
95   components ["non-free"]
96   key "C208ADDE26C2B797"
97 end
98
99 apt_repository "hwraid" do
100   action repository_actions["hwraid"]
101   uri "https://hwraid.le-vert.net/ubuntu"
102   distribution "precise"
103   components ["main"]
104   key "6005210E23B3D3B4"
105 end
106
107 apt_repository "nginx" do
108   action repository_actions["nginx"]
109   uri "https://nginx.org/packages/ubuntu"
110   components ["nginx"]
111   key "ABF5BD827BD9BF62"
112 end
113
114 apt_repository "elasticsearch5.x" do
115   action repository_actions["elasticsearch5.x"]
116   uri "https://artifacts.elastic.co/packages/5.x/apt"
117   distribution "stable"
118   components ["main"]
119   key "D27D666CD88E42B4"
120 end
121
122 apt_repository "logstash" do
123   action repository_actions["logstash"]
124   uri "https://packages.elasticsearch.org/logstash/2.3/debian"
125   distribution "stable"
126   components ["main"]
127   key "D27D666CD88E42B4"
128 end
129
130 apt_repository "passenger" do
131   action repository_actions["passenger"]
132   uri "https://oss-binaries.phusionpassenger.com/apt/passenger"
133   components ["main"]
134   key "561F9B9CAC40B2F7"
135 end
136
137 apt_repository "postgresql" do
138   action repository_actions["postgresql"]
139   uri "https://apt.postgresql.org/pub/repos/apt"
140   distribution "#{node[:lsb][:codename]}-pgdg"
141   components ["main"]
142   key "7FCC7D46ACCC4CF8"
143 end
144
145 apt_repository "mediawiki" do
146   action repository_actions["mediawiki"]
147   uri "https://releases.wikimedia.org/debian"
148   distribution "jessie-mediawiki"
149   components ["main"]
150   key "90E9F83F22250DD7"
151 end
152
153 package "unattended-upgrades"
154
155 if Dir.exist?("/usr/share/unattended-upgrades")
156   auto_upgrades = if node[:apt][:unattended_upgrades][:enable]
157                     IO.read("/usr/share/unattended-upgrades/20auto-upgrades")
158                   else
159                     IO.read("/usr/share/unattended-upgrades/20auto-upgrades-disabled")
160                   end
161
162   file "/etc/apt/apt.conf.d/20auto-upgrades" do
163     user "root"
164     group "root"
165     mode 0o644
166     content auto_upgrades
167   end
168 end
169
170 template "/etc/apt/apt.conf.d/60chef" do
171   source "apt.conf.erb"
172   owner "root"
173   group "root"
174   mode 0o644
175 end