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