]> git.openstreetmap.org Git - chef.git/blob - cookbooks/git/recipes/server.rb
c3382a2cf19ccd5b78ebe0e70a6feb4f913148a3
[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 firewall_rule "accept-git" do
48   action :accept
49   source "net"
50   dest "fw"
51   proto "tcp:syn"
52   dest_ports "git"
53   source_ports "1024:"
54 end
55
56 Dir.new(git_directory).select { |name| name =~ /\.git$/ }.each do |repository|
57   template "#{git_directory}/#{repository}/hooks/post-update" do
58     source "post-update.erb"
59     owner "root"
60     group "git"
61     mode 0755
62   end
63
64   if repository != "dns.git"
65     template "#{git_directory}/#{repository}/hooks/post-receive" do
66       source "post-receive.erb"
67       owner "root"
68       group "git"
69       mode 0755
70       variables :repository => "#{git_directory}/#{repository}"
71     end
72   end
73 end