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