]> git.openstreetmap.org Git - chef.git/commitdiff
Simplify generation of ACLs for munin and logstash
authorTom Hughes <tom@compton.nu>
Mon, 13 Mar 2023 20:57:10 +0000 (20:57 +0000)
committerTom Hughes <tom@compton.nu>
Mon, 13 Mar 2023 20:57:10 +0000 (20:57 +0000)
cookbooks/logstash/recipes/default.rb
cookbooks/munin/recipes/default.rb

index 34f731af29734698f9c9dddc0a157a32ba54bb8b..e3261d0d12852c7b25d027a0c0628f6d23f05921 100644 (file)
@@ -76,17 +76,13 @@ end
 
 forwarders = []
 
-search(:node, "recipes:logstash\\:\\:forwarder").each do |forwarder|
-  forwarder.interfaces(:role => :external).map do |interface|
-    forwarders << interface[:address]
-  end
-end
+forwarders << search(:node, "recipes:logstash\\:\\:forwarder").collect do |forwarder|
+  forwarder.ipaddresses(:role => :external)
+end.flatten
 
-search(:node, "roles:gateway").each do |forwarder|
-  forwarder.interfaces(:role => :external).map do |interface|
-    forwarders << interface[:address]
-  end
-end
+forwarders << search(:node, "roles:gateway").collect do |forwarder|
+  forwarder.ipaddresses(:role => :external)
+end.flatten
 
 firewall_rule "accept-logstash" do
   action :accept
index 0a2a344528159a0bb687300e6fa325170419f5ab..a54b387185fdde2a413b0db111b050cd29cde13c 100644 (file)
@@ -24,13 +24,9 @@ service "munin-node" do
   supports :status => true, :restart => true, :reload => true
 end
 
-servers = []
-
-search(:node, "recipes:munin\\:\\:server").each do |server|
-  server.interfaces(:role => :external) do |interface|
-    servers << interface[:address]
-  end
-end
+servers = search(:node, "recipes:munin\\:\\:server").collect do |server|
+  server.ipaddresses(:role => :external)
+end.flatten
 
 firewall_rule "accept-munin" do
   action :accept