From 8c1484ccac7f10b5f497a48295c04cbed1a01457 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Tue, 1 Oct 2013 18:54:25 +0100 Subject: [PATCH] Allow all tilecache servers to sync to the log store --- cookbooks/rsyncd/recipes/default.rb | 22 +++++++++++++++++++ .../rsyncd/templates/default/rsyncd.conf.erb | 8 +++---- roles/ironbelly.rb | 3 ++- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/cookbooks/rsyncd/recipes/default.rb b/cookbooks/rsyncd/recipes/default.rb index 5f090d1ce..56eb2f6ff 100644 --- a/cookbooks/rsyncd/recipes/default.rb +++ b/cookbooks/rsyncd/recipes/default.rb @@ -19,6 +19,27 @@ include_recipe "networking" +hosts_allow = Hash.new +hosts_deny = Hash.new + +node[:rsyncd][:modules].each do |name,details| + hosts_allow[name] = details[:hosts_allow] || [] + + if details[:nodes_allow] + hosts_allow[name] |= search(:node, details[:nodes_allow]).collect do |n| + n.ipaddresses(:role => :external) + end.flatten + end + + hosts_deny[name] = details[:hosts_deny] || [] + + if details[:nodes_deny] + hosts_deny[name] |= search(:node, details[:nodes_deny]).collect do |n| + n.ipaddresses(:role => :external) + end.flatten + end +end + package "rsync" service "rsync" do @@ -39,6 +60,7 @@ template "/etc/rsyncd.conf" do owner "root" group "root" mode 0644 + variables :hosts_allow => hosts_allow, :hosts_deny => hosts_deny end firewall_rule "accept-rsync" do diff --git a/cookbooks/rsyncd/templates/default/rsyncd.conf.erb b/cookbooks/rsyncd/templates/default/rsyncd.conf.erb index adc04a899..c70de0ba7 100644 --- a/cookbooks/rsyncd/templates/default/rsyncd.conf.erb +++ b/cookbooks/rsyncd/templates/default/rsyncd.conf.erb @@ -33,11 +33,11 @@ <% if details[:refuse_options] -%> refuse options = <%= details[:refuse_options].join(" ") %> <% end -%> -<% if details[:hosts_allow] -%> - hosts allow = <%= details[:hosts_allow].join(",") %> +<% unless @hosts_allow[name].empty? -%> + hosts allow = <%= @hosts_allow[name].join(",") %> <% end -%> -<% if details[:hosts_deny] -%> - hosts deny = <%= details[:hosts_deny].join(",") %> +<% unless @hosts_deny[name].empty? -%> + hosts deny = <%= @hosts_deny[name].join(",") %> <% end -%> dont compress = *.gz *.tgz *.zip *.z *.rpm *.deb *.iso *.bz2 *.tbz *.7z <% end -%> diff --git a/roles/ironbelly.rb b/roles/ironbelly.rb index c22a3c6c4..427e9ce9c 100644 --- a/roles/ironbelly.rb +++ b/roles/ironbelly.rb @@ -72,7 +72,8 @@ default_attributes( "2001:630:12:500::/64", # ic external "127.0.0.0/8", # localhost "::1" # localhost - ] + ], + :nodes_allow => "roles:tilecache" } } } -- 2.39.5