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 68d46547..5274b996 100644 --- a/resources/recipes/configure.rb +++ b/resources/recipes/configure.rb @@ -282,6 +282,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 3a8eac8e..7619da6a 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"] sync_net = `cat /etc/redborder/rb_init_conf.yml | grep sync_net | awk '{print $2'} | sed 's|/.*||'`.strip node['network']['interfaces'].each do |interface, details| @@ -95,6 +95,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