Skip to content

Commit

Permalink
logstash should not run when no pipelines
Browse files Browse the repository at this point in the history
  • Loading branch information
nilsver committed Jun 14, 2024
1 parent f66e148 commit 924ee84
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
2 changes: 1 addition & 1 deletion resources/libraries/get_pipelines.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
26 changes: 12 additions & 14 deletions resources/recipes/configure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion resources/recipes/prepare_system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 924ee84

Please sign in to comment.