]> git.openstreetmap.org Git - chef.git/blob - cookbooks/git/recipes/server.rb
12b576aa10730517be9f56579775fd101454618d
[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 "networking"
21
22 git_directory = node[:git][:directory]
23
24 directory git_directory do
25   owner "git"
26   group "git"
27   mode 02775
28 end
29
30 firewall_rule "accept-git" do
31   action :accept
32   source "net"
33   dest "fw"
34   proto "tcp:syn"
35   dest_ports "git"
36   source_ports "1024:"
37 end
38
39 Dir.new(git_directory).select { |name| name =~ /\.git$/ }.each do |repository|
40   template "#{git_directory}/#{repository}/hooks/post-update" do
41     source "post-update.erb"
42     owner "root"
43     group "git"
44     mode 0755
45   end
46
47   if repository != "dns.git"
48     template "#{git_directory}/#{repository}/hooks/post-receive" do
49       source "post-receive.erb"
50       owner "root"
51       group "git"
52       mode 0755
53       variables :repository => "#{git_directory}/#{repository}"
54     end
55   end
56 end
57
58 template "/etc/cron.daily/git-backup" do
59   source "backup.cron.erb"
60   owner "root"
61   group "root"
62   mode 0755
63 end