]> git.openstreetmap.org Git - chef.git/blob - cookbooks/stateofthemap/recipes/default.rb
17b07f39706e106cc6cde0f7b1019a7f0eeac426
[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 end
170
171 wordpress_plugin "2010.stateofthemap.org-wp-sticky" do
172   plugin "wp-sticky"
173   site "2010.stateofthemap.org"
174 end
175
176 directory "/srv/2011.stateofthemap.org" do
177   owner "wordpress"
178   group "wordpress"
179   mode 0o755
180 end
181
182 git "/srv/2011.stateofthemap.org" do
183   action :sync
184   repository "https://git.openstreetmap.org/public/stateofthemap.git"
185   revision "resources-2011"
186   user "wordpress"
187   group "wordpress"
188 end
189
190 wordpress_site "2011.stateofthemap.org" do
191   aliases "2011.stateofthemap.com"
192   directory "/srv/2011.stateofthemap.org/wp"
193   database_name "sotm2011"
194   database_user "sotm2011"
195   database_password passwords["sotm2011"]
196   urls "/register" => "/srv/2011.stateofthemap.org/register"
197 end
198
199 wordpress_theme "2011.stateofthemap.org-aerodrome" do
200   theme "aerodrome"
201   site "2011.stateofthemap.org"
202   repository "https://git.openstreetmap.org/public/stateofthemap.git"
203   revision "theme-2011"
204 end
205
206 wordpress_plugin "2011.stateofthemap.org-sitepress-multilingual-cms" do
207   plugin "sitepress-multilingual-cms"
208   site "2011.stateofthemap.org"
209   repository "https://git.openstreetmap.org/private/sitepress-multilingual-cms.git"
210 end
211
212 wordpress_plugin "2011.stateofthemap.org-wp-sticky" do
213   plugin "wp-sticky"
214   site "2011.stateofthemap.org"
215 end
216
217 directory "/srv/2012.stateofthemap.org" do
218   owner "wordpress"
219   group "wordpress"
220   mode 0o755
221 end
222
223 git "/srv/2012.stateofthemap.org" do
224   action :sync
225   repository "https://git.openstreetmap.org/public/stateofthemap.git"
226   revision "resources-2012"
227   user "wordpress"
228   group "wordpress"
229 end
230
231 wordpress_site "2012.stateofthemap.org" do
232   aliases "2012.stateofthemap.com"
233   directory "/srv/2012.stateofthemap.org/wp"
234   database_name "sotm2012"
235   database_user "sotm2012"
236   database_password passwords["sotm2012"]
237   urls "/register" => "/srv/2012.stateofthemap.org/register"
238 end
239
240 wordpress_theme "2012.stateofthemap.org-aerodrome" do
241   theme "aerodrome"
242   site "2012.stateofthemap.org"
243   repository "https://git.openstreetmap.org/public/stateofthemap.git"
244   revision "theme-2012"
245 end
246
247 wordpress_plugin "2012.stateofthemap.org-leaflet-maps-marker" do
248   plugin "leaflet-maps-marker"
249   site "2012.stateofthemap.org"
250 end
251
252 wordpress_plugin "2012.stateofthemap.org-sitepress-multilingual-cms" do
253   plugin "sitepress-multilingual-cms"
254   site "2012.stateofthemap.org"
255   repository "https://git.openstreetmap.org/private/sitepress-multilingual-cms.git"
256 end
257
258 wordpress_plugin "2012.stateofthemap.org-wp-sticky" do
259   plugin "wp-sticky"
260   site "2012.stateofthemap.org"
261 end
262
263 %w[2013].each do |year|
264   git "/srv/#{year}.stateofthemap.org" do
265     action :sync
266     repository "https://git.openstreetmap.org/public/stateofthemap.git"
267     revision "site-#{year}"
268     user "root"
269     group "root"
270   end
271
272   ssl_certificate "#{year}.stateofthemap.org" do
273     domains ["#{year}.stateofthemap.org", "#{year}.stateofthemap.com"]
274     notifies :reload, "service[apache2]"
275   end
276
277   apache_site "#{year}.stateofthemap.org" do
278     template "apache.static.erb"
279     directory "/srv/#{year}.stateofthemap.org"
280     variables :year => year
281   end
282 end
283
284 gem_package "jekyll"
285
286 %w[2016 2017 2018 2019 2020].each do |year|
287   git "/srv/#{year}.stateofthemap.org" do
288     action :sync
289     repository "git://github.com/openstreetmap/stateofthemap-#{year}.git"
290     user "root"
291     group "root"
292     notifies :run, "execute[/srv/#{year}.stateofthemap.org]"
293   end
294
295   directory "/srv/#{year}.stateofthemap.org/_site" do
296     mode 0o755
297     owner "nobody"
298     group "nogroup"
299   end
300
301   execute "/srv/#{year}.stateofthemap.org" do
302     action :nothing
303     command "jekyll build --trace"
304     cwd "/srv/#{year}.stateofthemap.org"
305     user "nobody"
306     group "nogroup"
307   end
308
309   ssl_certificate "#{year}.stateofthemap.org" do
310     domains ["#{year}.stateofthemap.org", "#{year}.stateofthemap.com"]
311     notifies :reload, "service[apache2]"
312   end
313
314   apache_site "#{year}.stateofthemap.org" do
315     template "apache.jekyll.erb"
316     directory "/srv/#{year}.stateofthemap.org/_site"
317     variables :year => year
318   end
319 end
320
321 template "/etc/cron.daily/sotm-backup" do
322   source "backup.cron.erb"
323   owner "root"
324   group "root"
325   mode 0o750
326   variables :passwords => passwords
327 end