]> git.openstreetmap.org Git - chef.git/blob - cookbooks/donate/recipes/default.rb
1c0a436f0266f873a27f36d187691bfb499f3872
[chef.git] / cookbooks / donate / recipes / default.rb
1 #
2 # Cookbook Name:: donate
3 # Recipe:: default
4 #
5 # Copyright 2016, 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 node.default[:ssl][:certificates] = node[:ssl][:certificates] | ["openstreetmap"]
21
22 include_recipe "apache::ssl"
23 include_recipe "mysql"
24 include_recipe "git"
25
26 if node[:lsb][:release].to_f >= 16.04
27   package "php"
28   package "php-cli"
29   package "php-curl"
30   package "php-mysql"
31   package "php-gd"
32
33   apache_module "php7.0"
34 else
35   package "php5"
36   package "php5-cli"
37   package "php5-curl"
38   package "php5-mysql"
39   package "php5-gd"
40
41   apache_module "php5"
42 end
43
44 apache_module "headers"
45
46 passwords = data_bag_item("donate", "passwords")
47
48 database_password = passwords["database"]
49
50 mysql_user "donate@localhost" do
51   password database_password
52 end
53
54 mysql_database "donate" do
55   permissions "donate@localhost" => :all
56 end
57
58 directory "/srv/donate.openstreetmap.org" do
59   owner "donate"
60   group "donate"
61   mode 0o755
62 end
63
64 git "/srv/donate.openstreetmap.org" do
65   action :sync
66   repository "git://github.com/osmfoundation/donation-drive.git"
67   user "donate"
68   group "donate"
69 end
70
71 directory "/srv/donate.openstreetmap.org/data" do
72   owner "donate"
73   group "donate"
74   mode 0o755
75 end
76
77 template "/srv/donate.openstreetmap.org/scripts/db-connect.inc.php" do
78   source "db-connect.inc.php.erb"
79   owner "root"
80   group "donate"
81   mode 0o644
82   variables :passwords => passwords
83 end
84
85 ssl_certificate "donate.openstreetmap.org" do
86   domains ["donate.openstreetmap.org", "donate.openstreetmap.com",
87            "donate.openstreetmap.net", "donate.osm.org"]
88   notifies :reload, "service[apache2]"
89 end
90
91 apache_site "donate.openstreetmap.org" do
92   template "apache.erb"
93 end
94
95 template "/etc/cron.d/osmf-donate" do
96   source "cron.erb"
97   owner "root"
98   group "root"
99   mode 0o600
100   variables :passwords => passwords
101 end
102
103 template "/etc/cron.daily/osmf-donate-backup" do
104   source "backup.cron.erb"
105   owner "root"
106   group "root"
107   mode 0o750
108   variables :passwords => passwords
109 end