]> git.openstreetmap.org Git - chef.git/blob - cookbooks/forum/recipes/default.rb
forum: use temporary theme location to workaround chef openssl bug
[chef.git] / cookbooks / forum / recipes / default.rb
1 #
2 # Cookbook:: forum
3 # Recipe:: default
4 #
5 # Copyright:: 2014, 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 "accounts"
21 include_recipe "apache"
22 include_recipe "git"
23 include_recipe "mysql"
24 include_recipe "php::apache"
25
26 cache_dir = Chef::Config[:file_cache_path]
27
28 passwords = data_bag_item("forum", "passwords")
29
30 package %w[
31   php-cli
32   php-mysql
33   php-xml
34   php-apcu
35   unzip
36 ]
37
38 apache_module "rewrite"
39
40 ssl_certificate "forum.openstreetmap.org" do
41   domains ["forum.openstreetmap.org", "forum.osm.org"]
42   notifies :reload, "service[apache2]"
43 end
44
45 apache_site "forum.openstreetmap.org" do
46   template "apache.erb"
47 end
48
49 directory "/srv/forum.openstreetmap.org" do
50   owner "forum"
51   group "forum"
52   mode 0o755
53 end
54
55 git "/srv/forum.openstreetmap.org/html/" do
56   action :sync
57   repository "http://github.com/openstreetmap/openstreetmap-forum.git"
58   revision "openstreetmap-1.5.10"
59   depth 1
60   user "forum"
61   group "forum"
62   notifies :reload, "service[apache2]"
63 end
64
65 remote_file "#{cache_dir}/air3_v0.8.zip" do
66   action :create_if_missing
67   source "https://grant.dev.openstreetmap.org/forum/air3_v0.8.zip" # Workaround OpenSSL chain of trust bug in chef https://fluxbb.org/resources/styles/air3/releases/0.8/air3_v0.8.zip
68   checksum "df547e3ac9596c1e6d9eedcb108559f84a28669763e24114ca6cdcbf118caf6c"
69   owner "root"
70   group "root"
71   mode 0o644
72   backup false
73 end
74
75 execute "#{cache_dir}/air3_v0.8.zip" do
76   action :nothing
77   command "unzip -o -qq #{cache_dir}/air3_v0.8.zip Air3.css 'Air3/*'"
78   cwd "/srv/forum.openstreetmap.org/html/style"
79   user "forum"
80   group "forum"
81   subscribes :run, "remote_file[#{cache_dir}/air3_v0.8.zip]", :immediately
82 end
83
84 directory "/srv/forum.openstreetmap.org/html/cache/" do
85   owner "www-data"
86   group "www-data"
87   mode 0o755
88 end
89
90 directory "/srv/forum.openstreetmap.org/html/img/avatars/" do
91   owner "www-data"
92   group "www-data"
93   mode 0o755
94 end
95
96 template "/srv/forum.openstreetmap.org/html/config.php" do
97   source "config.php.erb"
98   owner "forum"
99   group "www-data"
100   mode 0o440
101   variables :passwords => passwords
102 end
103
104 mysql_user "forum@localhost" do
105   password passwords["database"]
106 end
107
108 mysql_database "forum" do
109   permissions "forum@localhost" => :all
110 end
111
112 template "/etc/cron.daily/forum-backup" do
113   source "backup.cron.erb"
114   owner "root"
115   group "root"
116   mode 0o750
117   variables :passwords => passwords
118 end