]> git.openstreetmap.org Git - chef.git/blob - cookbooks/stateofthemap/recipes/default.rb
f0936381ff53463ace6046c2a7bb4a12082909b9
[chef.git] / cookbooks / stateofthemap / recipes / default.rb
1 #
2 # Cookbook Name:: 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 #     http://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 "git://git.openstreetmap.org/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   ssl_enabled true
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   name "refreshwp-11"
62   site "2007.stateofthemap.org"
63   repository "git://git.openstreetmap.org/stateofthemap.git"
64   revision "theme-2007"
65 end
66
67 wordpress_plugin "2007.stateofthemap.org-geopress" do
68   name "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   ssl_enabled true
82   database_name "sotm2008"
83   database_user "sotm2008"
84   database_password passwords["sotm2008"]
85   database_prefix "wp_sotm08_"
86 end
87
88 wordpress_theme "2008.stateofthemap.org-refreshwp-11" do
89   name "refreshwp-11"
90   site "2008.stateofthemap.org"
91   repository "git://git.openstreetmap.org/stateofthemap.git"
92   revision "theme-2008"
93 end
94
95 wordpress_plugin "2008.stateofthemap.org-geopress" do
96   name "geopress"
97   site "2008.stateofthemap.org"
98 end
99
100 directory "/srv/2009.stateofthemap.org" do
101   owner "wordpress"
102   group "wordpress"
103   mode 0o755
104 end
105
106 git "/srv/2009.stateofthemap.org" do
107   action :sync
108   repository "git://git.openstreetmap.org/stateofthemap.git"
109   revision "resources-2009"
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   ssl_enabled true
118   database_name "sotm2009"
119   database_user "sotm2009"
120   database_password passwords["sotm2009"]
121   urls "/register" => "/srv/2009.stateofthemap.org/register",
122        "/register-pro-user" => "/srv/2009.stateofthemap.org/register-pro-user",
123        "/podcasts" => "/srv/2009.stateofthemap.org/podcasts"
124 end
125
126 wordpress_theme "2009.stateofthemap.org-aerodrome" do
127   name "aerodrome"
128   site "2009.stateofthemap.org"
129   repository "git://git.openstreetmap.org/stateofthemap.git"
130   revision "theme-2009"
131 end
132
133 wordpress_plugin "2009.stateofthemap.org-wp-sticky" do
134   name "wp-sticky"
135   site "2009.stateofthemap.org"
136 end
137
138 directory "/srv/2010.stateofthemap.org" do
139   owner "wordpress"
140   group "wordpress"
141   mode 0o755
142 end
143
144 git "/srv/2010.stateofthemap.org" do
145   action :sync
146   repository "git://git.openstreetmap.org/stateofthemap.git"
147   revision "resources-2010"
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   ssl_enabled true
156   database_name "sotm2010"
157   database_user "sotm2010"
158   database_password passwords["sotm2010"]
159   urls "/register" => "/srv/2010.stateofthemap.org/register"
160 end
161
162 wordpress_theme "2010.stateofthemap.org-aerodrome" do
163   name "aerodrome"
164   site "2010.stateofthemap.org"
165   repository "git://git.openstreetmap.org/stateofthemap.git"
166   revision "theme-2010"
167 end
168
169 wordpress_plugin "2010.stateofthemap.org-sitepress-multilingual-cms" do
170   name "sitepress-multilingual-cms"
171   site "2010.stateofthemap.org"
172   repository "git://chef.openstreetmap.org/sitepress-multilingual-cms.git"
173 end
174
175 wordpress_plugin "2010.stateofthemap.org-wp-sticky" do
176   name "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 "git://git.openstreetmap.org/stateofthemap.git"
189   revision "resources-2011"
190   user "wordpress"
191   group "wordpress"
192 end
193
194 wordpress_site "2011.stateofthemap.org" do
195   aliases "2011.stateofthemap.com"
196   directory "/srv/2011.stateofthemap.org/wp"
197   ssl_enabled true
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   name "aerodrome"
206   site "2011.stateofthemap.org"
207   repository "git://git.openstreetmap.org/stateofthemap.git"
208   revision "theme-2011"
209 end
210
211 wordpress_plugin "2011.stateofthemap.org-sitepress-multilingual-cms" do
212   name "sitepress-multilingual-cms"
213   site "2011.stateofthemap.org"
214   repository "git://chef.openstreetmap.org/sitepress-multilingual-cms.git"
215 end
216
217 wordpress_plugin "2011.stateofthemap.org-wp-sticky" do
218   name "wp-sticky"
219   site "2011.stateofthemap.org"
220 end
221
222 directory "/srv/2012.stateofthemap.org" do
223   owner "wordpress"
224   group "wordpress"
225   mode 0o755
226 end
227
228 git "/srv/2012.stateofthemap.org" do
229   action :sync
230   repository "git://git.openstreetmap.org/stateofthemap.git"
231   revision "resources-2012"
232   user "wordpress"
233   group "wordpress"
234 end
235
236 wordpress_site "2012.stateofthemap.org" do
237   aliases "2012.stateofthemap.com"
238   directory "/srv/2012.stateofthemap.org/wp"
239   ssl_enabled true
240   database_name "sotm2012"
241   database_user "sotm2012"
242   database_password passwords["sotm2012"]
243   urls "/register" => "/srv/2012.stateofthemap.org/register"
244 end
245
246 wordpress_theme "2012.stateofthemap.org-aerodrome" do
247   name "aerodrome"
248   site "2012.stateofthemap.org"
249   repository "git://git.openstreetmap.org/stateofthemap.git"
250   revision "theme-2012"
251 end
252
253 wordpress_plugin "2012.stateofthemap.org-leaflet-maps-marker" do
254   name "leaflet-maps-marker"
255   site "2012.stateofthemap.org"
256 end
257
258 wordpress_plugin "2012.stateofthemap.org-sitepress-multilingual-cms" do
259   name "sitepress-multilingual-cms"
260   site "2012.stateofthemap.org"
261   repository "git://chef.openstreetmap.org/sitepress-multilingual-cms.git"
262 end
263
264 wordpress_plugin "2012.stateofthemap.org-wp-sticky" do
265   name "wp-sticky"
266   site "2012.stateofthemap.org"
267 end
268
269 %w[2016 2017 2018].each do |year|
270   git "/srv/#{year}.stateofthemap.org" do
271     action :sync
272     repository "git://github.com/openstreetmap/stateofthemap-#{year}.git"
273     user "root"
274     group "root"
275     notifies :run, "execute[/srv/#{year}.stateofthemap.org]"
276   end
277
278   directory "/srv/#{year}.stateofthemap.org/_site" do
279     mode 0o755
280     owner "nobody"
281     group "nogroup"
282   end
283
284   execute "/srv/#{year}.stateofthemap.org" do
285     action :nothing
286     command "jekyll build --trace"
287     cwd "/srv/#{year}.stateofthemap.org"
288     user "nobody"
289     group "nogroup"
290   end
291
292   ssl_certificate "#{year}.stateofthemap.org" do
293     domains ["#{year}.stateofthemap.org", "#{year}.stateofthemap.com"]
294     notifies :reload, "service[apache2]"
295   end
296
297   apache_site "#{year}.stateofthemap.org" do
298     template "apache.jekyll.erb"
299     directory "/srv/#{year}.stateofthemap.org/_site"
300     variables :year => year
301   end
302 end
303
304 template "/etc/cron.daily/sotm-backup" do
305   source "backup.cron.erb"
306   owner "root"
307   group "root"
308   mode 0o750
309   variables :passwords => passwords
310 end