From: Tom Hughes Date: Wed, 2 Oct 2013 18:11:35 +0000 (+0100) Subject: Allow access to a git server to be restricted to certain nodes X-Git-Url: https://git.openstreetmap.org./chef.git/commitdiff_plain/f7eea382e7a2a4964cc97251bc7ab977bddb7b95 Allow access to a git server to be restricted to certain nodes --- diff --git a/cookbooks/git/recipes/server.rb b/cookbooks/git/recipes/server.rb index 12b576aa1..4f537e62d 100644 --- a/cookbooks/git/recipes/server.rb +++ b/cookbooks/git/recipes/server.rb @@ -27,13 +27,29 @@ directory git_directory do mode 02775 end -firewall_rule "accept-git" do - action :accept - source "net" - dest "fw" - proto "tcp:syn" - dest_ports "git" - source_ports "1024:" +if node[:git][:allowed_nodes] + search(:node, node[:git][:allowed_nodes]).each do |n| + n.interfaces(:role => :external).each do |interface| + firewall_rule "accept-git" do + action :accept + family interface[:family] + source "#{interface[:zone]}:#{interface[:address]}" + dest "fw" + proto "tcp:syn" + dest_ports "git" + source_ports "1024:" + end + end + end +else + firewall_rule "accept-git" do + action :accept + source "net" + dest "fw" + proto "tcp:syn" + dest_ports "git" + source_ports "1024:" + end end Dir.new(git_directory).select { |name| name =~ /\.git$/ }.each do |repository|