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