]> git.openstreetmap.org Git - chef.git/blob - cookbooks/forum/recipes/default.rb
Use strings for file modes
[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 "env"
39 apache_module "rewrite"
40
41 ssl_certificate "forum.openstreetmap.org" do
42   domains ["forum.openstreetmap.org", "forum.osm.org"]
43   notifies :reload, "service[apache2]"
44 end
45
46 apache_site "forum.openstreetmap.org" do
47   template "apache.erb"
48 end
49
50 directory "/srv/forum.openstreetmap.org" do
51   owner "forum"
52   group "forum"
53   mode "755"
54 end
55
56 git "/srv/forum.openstreetmap.org/html/" do
57   action :sync
58   repository "http://github.com/openstreetmap/openstreetmap-forum.git"
59   revision "openstreetmap-1.5.10"
60   depth 1
61   user "forum"
62   group "forum"
63   notifies :reload, "service[apache2]"
64 end
65
66 remote_file "#{cache_dir}/air3_v0.8.zip" do
67   action :create_if_missing
68   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
69   checksum "df547e3ac9596c1e6d9eedcb108559f84a28669763e24114ca6cdcbf118caf6c"
70   owner "root"
71   group "root"
72   mode "644"
73   backup false
74 end
75
76 execute "#{cache_dir}/air3_v0.8.zip" do
77   action :nothing
78   command "unzip -o -qq #{cache_dir}/air3_v0.8.zip Air3.css 'Air3/*'"
79   cwd "/srv/forum.openstreetmap.org/html/style"
80   user "forum"
81   group "forum"
82   subscribes :run, "remote_file[#{cache_dir}/air3_v0.8.zip]", :immediately
83 end
84
85 directory "/srv/forum.openstreetmap.org/html/cache/" do
86   owner "www-data"
87   group "www-data"
88   mode "755"
89 end
90
91 directory "/srv/forum.openstreetmap.org/html/img/avatars/" do
92   owner "www-data"
93   group "www-data"
94   mode "755"
95 end
96
97 template "/srv/forum.openstreetmap.org/html/config.php" do
98   source "config.php.erb"
99   owner "forum"
100   group "www-data"
101   mode "440"
102   variables :passwords => passwords
103 end
104
105 mysql_user "forum@localhost" do
106   password passwords["database"]
107 end
108
109 mysql_database "forum" do
110   permissions "forum@localhost" => :all
111 end
112
113 template "/etc/cron.daily/forum-backup" do
114   source "backup.cron.erb"
115   owner "root"
116   group "root"
117   mode "750"
118   variables :passwords => passwords
119 end