]> git.openstreetmap.org Git - chef.git/blob - cookbooks/stateofthemap/recipes/default.rb
Update rubocop configuration for COP renames
[chef.git] / cookbooks / stateofthemap / recipes / default.rb
1 #
2 # Cookbook:: stateofthemap
3 # Recipe:: default
4 #
5 # Copyright:: 2013, OpenStreetMap Foundation
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 include_recipe "wordpress"
21
22 passwords = data_bag_item("stateofthemap", "passwords")
23
24 git "/srv/stateofthemap.org" do
25   action :sync
26   repository "https://git.openstreetmap.org/public/stateofthemap.git"
27   revision "chooser"
28   depth 1
29   user "root"
30   group "root"
31 end
32
33 ssl_certificate "stateofthemap.org" do
34   domains ["stateofthemap.org", "www.stateofthemap.org",
35            "stateofthemap.com", "www.stateofthemap.com",
36            "sotm.org", "www.sotm.org"]
37   notifies :reload, "service[apache2]"
38 end
39
40 apache_site "stateofthemap.org" do
41   template "apache.erb"
42   directory "/srv/stateofthemap.org"
43 end
44
45 directory "/srv/2007.stateofthemap.org" do
46   owner "wordpress"
47   group "wordpress"
48   mode 0o755
49 end
50
51 wordpress_site "2007.stateofthemap.org" do
52   aliases "2007.stateofthemap.com"
53   directory "/srv/2007.stateofthemap.org/wp"
54   database_name "sotm2007"
55   database_user "sotm2007"
56   database_password passwords["sotm2007"]
57   database_prefix "wp_sotm_"
58 end
59
60 wordpress_theme "2007.stateofthemap.org-refreshwp-11" do
61   theme "refreshwp-11"
62   site "2007.stateofthemap.org"
63   repository "https://git.openstreetmap.org/public/stateofthemap.git"
64   revision "theme-2007"
65 end
66
67 wordpress_plugin "2007.stateofthemap.org-geopress" do
68   plugin "geopress"
69   site "2007.stateofthemap.org"
70 end
71
72 directory "/srv/2008.stateofthemap.org" do
73   owner "wordpress"
74   group "wordpress"
75   mode 0o755
76 end
77
78 wordpress_site "2008.stateofthemap.org" do
79   aliases "2008.stateofthemap.com"
80   directory "/srv/2008.stateofthemap.org/wp"
81   database_name "sotm2008"
82   database_user "sotm2008"
83   database_password passwords["sotm2008"]
84   database_prefix "wp_sotm08_"
85 end
86
87 wordpress_theme "2008.stateofthemap.org-refreshwp-11" do
88   theme "refreshwp-11"
89   site "2008.stateofthemap.org"
90   repository "https://git.openstreetmap.org/public/stateofthemap.git"
91   revision "theme-2008"
92 end
93
94 wordpress_plugin "2008.stateofthemap.org-geopress" do
95   plugin "geopress"
96   site "2008.stateofthemap.org"
97 end
98
99 directory "/srv/2009.stateofthemap.org" do
100   owner "wordpress"
101   group "wordpress"
102   mode 0o755
103 end
104
105 git "/srv/2009.stateofthemap.org" do
106   action :sync
107   repository "https://git.openstreetmap.org/public/stateofthemap.git"
108   revision "resources-2009"
109   depth 1
110   user "wordpress"
111   group "wordpress"
112 end
113
114 wordpress_site "2009.stateofthemap.org" do
115   aliases "2009.stateofthemap.com"
116   directory "/srv/2009.stateofthemap.org/wp"
117   database_name "sotm2009"
118   database_user "sotm2009"
119   database_password passwords["sotm2009"]
120   urls "/register" => "/srv/2009.stateofthemap.org/register",
121        "/register-pro-user" => "/srv/2009.stateofthemap.org/register-pro-user",
122        "/podcasts" => "/srv/2009.stateofthemap.org/podcasts"
123 end
124
125 wordpress_theme "2009.stateofthemap.org-aerodrome" do
126   theme "aerodrome"
127   site "2009.stateofthemap.org"
128   repository "https://git.openstreetmap.org/public/stateofthemap.git"
129   revision "theme-2009"
130 end
131
132 wordpress_plugin "2009.stateofthemap.org-wp-sticky" do
133   plugin "wp-sticky"
134   site "2009.stateofthemap.org"
135 end
136
137 directory "/srv/2010.stateofthemap.org" do
138   owner "wordpress"
139   group "wordpress"
140   mode 0o755
141 end
142
143 git "/srv/2010.stateofthemap.org" do
144   action :sync
145   repository "https://git.openstreetmap.org/public/stateofthemap.git"
146   revision "resources-2010"
147   depth 1
148   user "wordpress"
149   group "wordpress"
150 end
151
152 wordpress_site "2010.stateofthemap.org" do
153   aliases "2010.stateofthemap.com"
154   directory "/srv/2010.stateofthemap.org/wp"
155   database_name "sotm2010"
156   database_user "sotm2010"
157   database_password passwords["sotm2010"]
158   urls "/register" => "/srv/2010.stateofthemap.org/register"
159 end
160
161 wordpress_theme "2010.stateofthemap.org-aerodrome" do
162   theme "aerodrome"
163   site "2010.stateofthemap.org"
164   repository "https://git.openstreetmap.org/public/stateofthemap.git"
165   revision "theme-2010"
166 end
167
168 wordpress_plugin "2010.stateofthemap.org-sitepress-multilingual-cms" do
169   plugin "sitepress-multilingual-cms"
170   site "2010.stateofthemap.org"
171   repository "https://git.openstreetmap.org/private/sitepress-multilingual-cms.git"
172   not_if { ENV["TEST_KITCHEN"] }
173 end
174
175 wordpress_plugin "2010.stateofthemap.org-wp-sticky" do
176   plugin "wp-sticky"
177   site "2010.stateofthemap.org"
178 end
179
180 directory "/srv/2011.stateofthemap.org" do
181   owner "wordpress"
182   group "wordpress"
183   mode 0o755
184 end
185
186 git "/srv/2011.stateofthemap.org" do
187   action :sync
188   repository "https://git.openstreetmap.org/public/stateofthemap.git"
189   revision "resources-2011"
190   depth 1
191   user "wordpress"
192   group "wordpress"
193 end
194
195 wordpress_site "2011.stateofthemap.org" do
196   aliases "2011.stateofthemap.com"
197   directory "/srv/2011.stateofthemap.org/wp"
198   database_name "sotm2011"
199   database_user "sotm2011"
200   database_password passwords["sotm2011"]
201   urls "/register" => "/srv/2011.stateofthemap.org/register"
202 end
203
204 wordpress_theme "2011.stateofthemap.org-aerodrome" do
205   theme "aerodrome"
206   site "2011.stateofthemap.org"
207   repository "https://git.openstreetmap.org/public/stateofthemap.git"
208   revision "theme-2011"
209 end
210
211 wordpress_plugin "2011.stateofthemap.org-sitepress-multilingual-cms" do
212   plugin "sitepress-multilingual-cms"
213   site "2011.stateofthemap.org"
214   repository "https://git.openstreetmap.org/private/sitepress-multilingual-cms.git"
215   not_if { ENV["TEST_KITCHEN"] }
216 end
217
218 wordpress_plugin "2011.stateofthemap.org-wp-sticky" do
219   plugin "wp-sticky"
220   site "2011.stateofthemap.org"
221 end
222
223 directory "/srv/2012.stateofthemap.org" do
224   owner "wordpress"
225   group "wordpress"
226   mode 0o755
227 end
228
229 git "/srv/2012.stateofthemap.org" do
230   action :sync
231   repository "https://git.openstreetmap.org/public/stateofthemap.git"
232   revision "resources-2012"
233   depth 1
234   user "wordpress"
235   group "wordpress"
236 end
237
238 wordpress_site "2012.stateofthemap.org" do
239   aliases "2012.stateofthemap.com"
240   directory "/srv/2012.stateofthemap.org/wp"
241   database_name "sotm2012"
242   database_user "sotm2012"
243   database_password passwords["sotm2012"]
244   urls "/register" => "/srv/2012.stateofthemap.org/register"
245 end
246
247 wordpress_theme "2012.stateofthemap.org-aerodrome" do
248   theme "aerodrome"
249   site "2012.stateofthemap.org"
250   repository "https://git.openstreetmap.org/public/stateofthemap.git"
251   revision "theme-2012"
252 end
253
254 wordpress_plugin "2012.stateofthemap.org-leaflet-maps-marker" do
255   plugin "leaflet-maps-marker"
256   site "2012.stateofthemap.org"
257 end
258
259 wordpress_plugin "2012.stateofthemap.org-sitepress-multilingual-cms" do
260   plugin "sitepress-multilingual-cms"
261   site "2012.stateofthemap.org"
262   repository "https://git.openstreetmap.org/private/sitepress-multilingual-cms.git"
263   not_if { ENV["TEST_KITCHEN"] }
264 end
265
266 wordpress_plugin "2012.stateofthemap.org-wp-sticky" do
267   plugin "wp-sticky"
268   site "2012.stateofthemap.org"
269 end
270
271 %w[2013].each do |year|
272   git "/srv/#{year}.stateofthemap.org" do
273     action :sync
274     repository "https://git.openstreetmap.org/public/stateofthemap.git"
275     revision "site-#{year}"
276     depth 1
277     user "root"
278     group "root"
279   end
280
281   ssl_certificate "#{year}.stateofthemap.org" do
282     domains ["#{year}.stateofthemap.org", "#{year}.stateofthemap.com", "#{year}.sotm.org"]
283     notifies :reload, "service[apache2]"
284   end
285
286   apache_site "#{year}.stateofthemap.org" do
287     template "apache.static.erb"
288     directory "/srv/#{year}.stateofthemap.org"
289     variables :year => year
290   end
291 end
292
293 package %w[
294   ruby
295   ruby-dev
296   libssl-dev
297   zlib1g-dev
298   pkg-config
299 ]
300
301 apache_module "expires"
302 apache_module "rewrite"
303
304 gem_package "bundler" do
305   version "1.17.3"
306 end
307
308 %w[2016 2017 2018 2019 2020].each do |year|
309   git "/srv/#{year}.stateofthemap.org" do
310     action :sync
311     repository "https://github.com/openstreetmap/stateofthemap-#{year}.git"
312     depth 1
313     user "root"
314     group "root"
315     notifies :run, "execute[/srv/#{year}.stateofthemap.org/Gemfile]"
316   end
317
318   directory "/srv/#{year}.stateofthemap.org/_site" do
319     mode 0o755
320     owner "nobody"
321     group "nogroup"
322   end
323
324   # Workaround https://github.com/jekyll/jekyll/issues/7804
325   # by creating a .jekyll-cache folder
326   directory "/srv/#{year}.stateofthemap.org/.jekyll-cache" do
327     mode 0o755
328     owner "nobody"
329     group "nogroup"
330   end
331
332   execute "/srv/#{year}.stateofthemap.org/Gemfile" do
333     action :nothing
334     command "bundle install --deployment"
335     cwd "/srv/#{year}.stateofthemap.org"
336     user "root"
337     group "root"
338     notifies :run, "execute[/srv/#{year}.stateofthemap.org]"
339     only_if { ::File.exist?("/srv/#{year}.stateofthemap.org/Gemfile") }
340   end
341
342   execute "/srv/#{year}.stateofthemap.org" do
343     action :nothing
344     command "bundle exec jekyll build --trace --baseurl=https://#{year}.stateofthemap.org"
345     cwd "/srv/#{year}.stateofthemap.org"
346     user "nobody"
347     group "nogroup"
348   end
349
350   ssl_certificate "#{year}.stateofthemap.org" do
351     domains ["#{year}.stateofthemap.org", "#{year}.stateofthemap.com", "#{year}.sotm.org"]
352     notifies :reload, "service[apache2]"
353   end
354
355   apache_site "#{year}.stateofthemap.org" do
356     template "apache.jekyll.erb"
357     directory "/srv/#{year}.stateofthemap.org/_site"
358     variables :year => year
359   end
360 end
361
362 template "/etc/cron.daily/sotm-backup" do
363   source "backup.cron.erb"
364   owner "root"
365   group "root"
366   mode 0o750
367   variables :passwords => passwords
368 end