]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/logstash/recipes/default.rb
Switch to use filebeat for forwarding to logstash
[chef.git] / cookbooks / logstash / recipes / default.rb
index fd758d8802237bc0bf9d8baae3599bd20c05a334..df54a728067c21eb1a77448c72ccfa11147bc4b1 100644 (file)
@@ -8,7 +8,7 @@
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at
 #
-#     http://www.apache.org/licenses/LICENSE-2.0
+#     https://www.apache.org/licenses/LICENSE-2.0
 #
 # Unless required by applicable law or agreed to in writing, software
 # distributed under the License is distributed on an "AS IS" BASIS,
@@ -42,6 +42,22 @@ file "/var/lib/logstash/lumberjack.key" do
   notifies :restart, "service[logstash]"
 end
 
+cookbook_file "/var/lib/logstash/beats.crt" do
+  source "beats.crt"
+  user "root"
+  group "logstash"
+  mode 0o644
+  notifies :restart, "service[logstash]"
+end
+
+file "/var/lib/logstash/beats.key" do
+  content keys["beats"].join("\n")
+  user "root"
+  group "logstash"
+  mode 0o640
+  notifies :restart, "service[logstash]"
+end
+
 template "/etc/logstash/conf.d/chef.conf" do
   source "logstash.conf.erb"
   user "root"
@@ -79,6 +95,16 @@ forwarders.sort_by { |n| n[:fqdn] }.each do |forwarder|
       dest_ports "5043"
       source_ports "1024:"
     end
+
+    firewall_rule "accept-beats-#{forwarder}" do
+      action :accept
+      family interface[:family]
+      source "#{interface[:zone]}:#{interface[:address]}"
+      dest "fw"
+      proto "tcp:syn"
+      dest_ports "5044"
+      source_ports "1024:"
+    end
   end
 end
 
@@ -95,5 +121,15 @@ gateways.sort_by { |n| n[:fqdn] }.each do |gateway|
       dest_ports "5043"
       source_ports "1024:"
     end
+
+    firewall_rule "accept-beats-#{gateway}" do
+      action :accept
+      family interface[:family]
+      source "#{interface[:zone]}:#{interface[:address]}"
+      dest "fw"
+      proto "tcp:syn"
+      dest_ports "5044"
+      source_ports "1024:"
+    end
   end
 end