]> git.openstreetmap.org Git - chef.git/blob - cookbooks/git/recipes/server.rb
66f4dd1fc01a558228dcd7025fde6b5d59ffb10a
[chef.git] / cookbooks / git / recipes / server.rb
1 #
2 # Cookbook Name:: git
3 # Recipe:: server
4 #
5 # Copyright 2011, 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 "networking"
22
23 package "gitweb"
24
25 apache_module "rewrite"
26
27 git_directory = node[:git][:directory]
28
29 directory git_directory do
30   owner "git"
31   group "git"
32   mode 02775
33 end
34
35 template "/etc/gitweb.conf" do
36   source "gitweb.conf.erb"
37   owner "root"
38   group "root"
39   mode 0644
40 end
41
42 apache_site node[:git][:host] do
43   template "apache.erb"
44   directory git_directory
45 end
46
47 template "#{git_directory}/robots.txt" do
48   source "robots.txt.erb"
49   owner "root"
50   group "root"
51   mode 0644
52 end
53
54 firewall_rule "accept-git" do
55   action :accept
56   source "net"
57   dest "fw"
58   proto "tcp:syn"
59   dest_ports "git"
60   source_ports "1024:"
61 end
62
63 Dir.new(git_directory).select { |name| name =~ /\.git$/ }.each do |repository|
64   template "#{git_directory}/#{repository}/hooks/post-update" do
65     source "post-update.erb"
66     owner "root"
67     group "git"
68     mode 0755
69   end
70
71   if repository != "dns.git"
72     template "#{git_directory}/#{repository}/hooks/post-receive" do
73       source "post-receive.erb"
74       owner "root"
75       group "git"
76       mode 0755
77       variables :repository => "#{git_directory}/#{repository}"
78     end
79   end
80 end
81
82 template "/etc/cron.daily/git-backup" do
83   source "backup.cron.erb"
84   owner "root"
85   group "root"
86   mode 0755
87 end