]> git.openstreetmap.org Git - chef.git/blob - cookbooks/trac/recipes/default.rb
Merge remote-tracking branch 'github/pull/422'
[chef.git] / cookbooks / trac / recipes / default.rb
1 #
2 # Cookbook:: trac
3 # Recipe:: default
4 #
5 # Copyright:: 2012, 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
23 package %w[
24   trac
25   ruby
26 ]
27
28 site_name = "trac.openstreetmap.org"
29 site_directory = "/srv/#{site_name}"
30
31 directory "/var/lib/trac" do
32   owner "trac"
33   group "trac"
34   mode "755"
35 end
36
37 execute "trac-initenv-#{site_name}" do
38   command "trac-admin /var/lib/trac initenv #{site_name} sqlite:db/trac.db"
39   user "trac"
40   group "trac"
41   not_if { ::File.exist?("/var/lib/trac/VERSION") }
42 end
43
44 template "/var/lib/trac/conf/trac.ini" do
45   source "trac.ini.erb"
46   owner "trac"
47   group "www-data"
48   mode "644"
49   variables :name => site_name
50 end
51
52 remote_directory "/var/lib/trac/htdocs" do
53   source "htdocs"
54   owner "trac"
55   group "trac"
56   mode "755"
57   files_owner "trac"
58   files_group "trac"
59   files_mode "644"
60   purge true
61 end
62
63 remote_directory "/var/lib/trac/templates" do
64   source "templates"
65   owner "trac"
66   group "trac"
67   mode "755"
68   files_owner "trac"
69   files_group "trac"
70   files_mode "644"
71   purge true
72 end
73
74 execute "trac-deploy-#{site_name}" do
75   command "trac-admin /var/lib/trac deploy #{site_directory}"
76   user "root"
77   group "root"
78   not_if { ::File.exist?(site_directory) }
79 end
80
81 cookbook_file "/usr/local/bin/trac-authenticate" do
82   owner "root"
83   group "root"
84   mode "755"
85 end
86
87 apache_module "wsgi"
88
89 apache_module "authnz_external" do
90   package "libapache2-mod-authnz-external"
91 end
92
93 ssl_certificate "trac.openstreetmap.org" do
94   domains ["trac.openstreetmap.org", "trac.osm.org"]
95   notifies :reload, "service[apache2]"
96 end
97
98 apache_site site_name do
99   template "apache.erb"
100   directory site_directory
101   variables :user => "trac", :group => "trac", :aliases => ["trac.osm.org"]
102 end
103
104 template "/etc/sudoers.d/trac" do
105   source "sudoers.erb"
106   owner "root"
107   group "root"
108   mode "440"
109 end
110
111 template "/etc/cron.daily/trac-backup" do
112   source "backup.cron.erb"
113   owner "root"
114   group "root"
115   mode "755"
116 end