From 924ee842e4e35c57c34e91ed972432807fa70379 Mon Sep 17 00:00:00 2001 From: nilsver Date: Fri, 14 Jun 2024 08:35:25 +0100 Subject: [PATCH 1/2] logstash should not run when no pipelines --- resources/libraries/get_pipelines.rb | 2 +- resources/recipes/configure.rb | 26 ++++++++++++-------------- resources/recipes/prepare_system.rb | 2 +- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/resources/libraries/get_pipelines.rb b/resources/libraries/get_pipelines.rb index c84920d6..d32c02c6 100644 --- a/resources/libraries/get_pipelines.rb +++ b/resources/libraries/get_pipelines.rb @@ -3,7 +3,7 @@ module Helpers def get_pipelines() logstash_pipelines = [] - sensors = node["redborder"]["sensors_info_all"] + sensors = get_sensors_info() namespaces = get_namespaces() main_logstash = determine_main_logstash_node() diff --git a/resources/recipes/configure.rb b/resources/recipes/configure.rb index 2585a38e..17bf7db4 100644 --- a/resources/recipes/configure.rb +++ b/resources/recipes/configure.rb @@ -275,20 +275,18 @@ action (manager_services["pmacct"] ? [:add, :register] : [:remove, :deregister]) end -if node["redborder"]["logstash"]["pipelines"].nil? || node["redborder"]["logstash"]["pipelines"].empty? - service 'logstash' do - action [:disable, :stop] - end -else - logstash_config "Configure logstash" do - cdomain node["redborder"]["cdomain"] - flow_nodes node["redborder"]["all_flow_sensors_info"]["flow-sensor"] - namespaces node["redborder"]["namespaces"] - 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]) +logstash_config 'Configure logstash' do + cdomain node['redborder']['cdomain'] + flow_nodes node.run_state['all_flow_sensors_info']['flow-sensor'] + namespaces node.run_state['namespaces'] + vault_nodes node.run_state['sensors_info_all']['vault-sensor'] + scanner_nodes node.run_state['sensors_info_all']['scanner-sensor'] + device_nodes node.run_state['sensors_info_all']['device-sensor'] + logstash_pipelines node.default['pipelines'] + if manager_services['logstash'] && node.default['pipelines'] && !node.default['pipelines'].empty? + action [:add, :register] + else + action [:remove, :deregister] end end diff --git a/resources/recipes/prepare_system.rb b/resources/recipes/prepare_system.rb index 0f97e046..cc47f63b 100644 --- a/resources/recipes/prepare_system.rb +++ b/resources/recipes/prepare_system.rb @@ -96,7 +96,7 @@ node.default["redborder"]["all_flow_sensors_info"] = get_all_flow_sensors_info() #get logstash pipelines -node.default["redborder"]["logstash"]["pipelines"] = get_pipelines() +node.default["pipelines"] = get_pipelines() #get namespaces node.default["redborder"]["namespaces"] = get_namespaces From ce4a03f64ff331b1cf35de8cd5291e32b8cdbdac Mon Sep 17 00:00:00 2001 From: nilsver <139124949+nilsver@users.noreply.github.com> Date: Fri, 14 Jun 2024 08:37:10 +0100 Subject: [PATCH 2/2] Update prepare_system.rb --- resources/recipes/prepare_system.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/recipes/prepare_system.rb b/resources/recipes/prepare_system.rb index cc47f63b..52e08058 100644 --- a/resources/recipes/prepare_system.rb +++ b/resources/recipes/prepare_system.rb @@ -95,8 +95,8 @@ #get sensors info of all flow sensors node.default["redborder"]["all_flow_sensors_info"] = get_all_flow_sensors_info() -#get logstash pipelines -node.default["pipelines"] = get_pipelines() +# get logstash pipelines +node.default['pipelines'] = get_pipelines() #get namespaces node.default["redborder"]["namespaces"] = get_namespaces