From 3268d477161c2ad5e52ba4c16f8224a4935d3334 Mon Sep 17 00:00:00 2001 From: nilsver Date: Tue, 30 Apr 2024 14:27:39 +0100 Subject: [PATCH] imported logstash template from centos6 --- resources/libraries/get_pipelines.rb | 38 ++++++++++++++++++++++++++++ resources/recipes/configure.rb | 1 + resources/recipes/prepare_system.rb | 5 +++- 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 resources/libraries/get_pipelines.rb diff --git a/resources/libraries/get_pipelines.rb b/resources/libraries/get_pipelines.rb new file mode 100644 index 00000000..f078c5d3 --- /dev/null +++ b/resources/libraries/get_pipelines.rb @@ -0,0 +1,38 @@ +module Rb_manager + module Helpers + + def get_pipelines() + logstash_pipelines = [] + sensors = node["redborder"]["sensors_info_all"] + namespaces = get_namespaces() + main_logstash = determine_main_logstash_node() + + if manager_services["logstash"] + logstash_pipelines.push("rbwindow-pipeline") if main_logstash == node.name + logstash_pipelines.push("apstate-pipeline") + logstash_pipelines.push("scanner-pipeline") unless sensors["scanner-sensor"].empty? + logstash_pipelines.push("nmsp-pipeline") if main_logstash == node.name and !sensors["flow-sensor"].empty? + logstash_pipelines.push("radius-pipeline") if main_logstash == node.name + logstash_pipelines.push("vault-pipeline") unless sensors["vault-sensor"].empty? + logstash_pipelines.push("netflow-pipeline") unless sensors["flow-sensor"].empty? + logstash_pipelines.push("sflow-pipeline") unless sensors["flow-sensor"].empty? + logstash_pipelines.push("meraki-pipeline") unless sensors["meraki-sensor"].empty? + logstash_pipelines.push("monitor-pipeline") unless namespaces.empty? + logstash_pipelines.push("location-pipeline") unless sensors["ale-sensor"].empty? or sensors["mse-sensor"].empty? or sensors["flow-sensor"].empty? or sensors["arubacentral-sensor"].empty? + logstash_pipelines.push("mobility-pipeline") + logstash_pipelines.push("redfish-pipeline") unless sensors["device-sensor"].empty? + logstash_pipelines.push("bulkstats-pipeline") unless sensors["device-sensor"].empty? + end + end + + # The main logstash is a node where both memcached and logstash are running or the first logstash node (order by name). + # This main logasths node is gonna run the pipelines rbwindow, location, mobility, nmsp, meraki and radius + # Those pipelines should only run in one node (the main_logstash node) for now.. + def determine_main_logstash_node() + memcached_nodes = managers_per_service["memcached"].sort.uniq + logstash_nodes = managers_per_service["logstash"].sort.uniq + main_logstash_nodes = memcached_nodes & logstash_nodes + main_logstash_nodes.first || logstash_nodes.first + end + end +end diff --git a/resources/recipes/configure.rb b/resources/recipes/configure.rb index 7f118d36..a8117d43 100644 --- a/resources/recipes/configure.rb +++ b/resources/recipes/configure.rb @@ -280,6 +280,7 @@ vault_nodes node["redborder"]["sensors_info_all"]["vault-sensor"] scanner_nodes node["redborder"]["sensors_info_all"]["scanner-sensor"] device_nodes node["redborder"]["sensors_info_all"]["device-sensor"] + logstash_pipelines node["redborder"]["logstash"]["pipelines"] action (manager_services["logstash"] ? [:add, :register] : [:remove, :deregister]) end diff --git a/resources/recipes/prepare_system.rb b/resources/recipes/prepare_system.rb index a9b9d2d7..77053754 100644 --- a/resources/recipes/prepare_system.rb +++ b/resources/recipes/prepare_system.rb @@ -22,7 +22,7 @@ node.default["redborder"]["services"]["consul-client"] = true end -#Set :ipaddress_sync +#Set :ipaddress_sync ipaddress_sync=node["ipaddress"] node['network']['interfaces'].each do |interface, details| next unless "x#{interface}" != "xlo" @@ -94,6 +94,9 @@ #get sensors info of all flow sensors node.default["redborder"]["all_flow_sensors_info"] = get_all_flow_sensors_info() +#get logstash pipelines +node.default["redborder"]["logstash"]["pipelines"] = get_pipelines() + #get namespaces node.default["redborder"]["namespaces"] = get_namespaces