]> git.openstreetmap.org Git - chef.git/blob - cookbooks/donate/recipes/default.rb
c5ab30ebe6f868ab62fdfb36b433e5e076858210
[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::ssl"
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-mysql"
28   package "php-gd"
29
30   apache_module "php7.0"
31 else
32   package "php5"
33   package "php5-cli"
34   package "php5-mysql"
35   package "php5-gd"
36
37   apache_module "php5"
38 end
39
40 apache_module "headers"
41
42 passwords = data_bag_item("donate", "passwords")
43
44 database_password = passwords["database"]
45
46 mysql_user "donate@localhost" do
47   password database_password
48 end
49
50 mysql_database "donate" do
51   permissions "donate@localhost" => :all
52 end
53
54 git "/srv/donate.openstreetmap.org" do
55   action :sync
56   repository "git://github.com/osmfoundation/donation-drive.git"
57   user "donate"
58   group "donate"
59 end
60
61 apache_site "donate.openstreetmap.org" do
62   template "apache.erb"
63 end
64
65 template "/etc/cron.d/osmf-donate" do
66   source "cron.erb"
67   owner "root"
68   group "root"
69   mode 0o600
70   variables :passwords => passwords
71 end
72
73 template "/etc/cron.daily/osmf-donate-backup" do
74   source "backup.cron.erb"
75   owner "root"
76   group "root"
77   mode 0o750
78   variables :passwords => passwords
79 end