]> git.openstreetmap.org Git - chef.git/blob - cookbooks/forum/recipes/default.rb
subversion: Disable svn.osm.org and add redirect
[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::fpm"
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 ]
36
37 apache_module "env"
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 php_fpm "forum.openstreetmap.org" do
46   php_admin_values "open_basedir" => "/srv/forum.openstreetmap.org/html/:/usr/share/php/:/tmp/",
47                    "disable_functions" => "exec,shell_exec,system,passthru,popen,proc_open"
48   prometheus_port 9253
49 end
50
51 apache_site "forum.openstreetmap.org" do
52   template "apache.erb"
53 end
54
55 directory "/srv/forum.openstreetmap.org" do
56   owner "forum"
57   group "forum"
58   mode "755"
59 end
60
61 git "/srv/forum.openstreetmap.org/html/" do
62   action :sync
63   repository "http://github.com/openstreetmap/openstreetmap-forum.git"
64   revision "openstreetmap-1.5.10"
65   depth 1
66   user "forum"
67   group "forum"
68   notifies :reload, "service[apache2]"
69 end
70
71 remote_file "#{cache_dir}/air3_v0.8.tar.gz" do
72   action :create_if_missing
73   source "https://github.com/natrius/air3/archive/refs/tags/v0.8.tar.gz"
74   owner "root"
75   group "root"
76   mode "644"
77   backup false
78 end
79
80 archive_file "#{cache_dir}/air3_v0.8.tar.gz" do
81   action :nothing
82   destination "/srv/forum.openstreetmap.org/html/style"
83   strip_components 1
84   overwrite true
85   owner "forum"
86   group "forum"
87   subscribes :extract, "remote_file[#{cache_dir}/air3_v0.8.tar.gz]", :immediately
88 end
89
90 directory "/srv/forum.openstreetmap.org/html/cache/" do
91   owner "www-data"
92   group "www-data"
93   mode "755"
94 end
95
96 directory "/srv/forum.openstreetmap.org/html/img/avatars/" do
97   owner "www-data"
98   group "www-data"
99   mode "755"
100 end
101
102 template "/srv/forum.openstreetmap.org/html/config.php" do
103   source "config.php.erb"
104   owner "forum"
105   group "www-data"
106   mode "440"
107   variables :passwords => passwords
108 end
109
110 mysql_user "forum@localhost" do
111   password passwords["database"]
112 end
113
114 mysql_database "forum" do
115   permissions "forum@localhost" => :all
116 end
117
118 template "/etc/cron.daily/forum-backup" do
119   source "backup.cron.erb"
120   owner "root"
121   group "root"
122   mode "750"
123   variables :passwords => passwords
124 end