Skip to content

Commit

Permalink
add temporary variables in node.run_state
Browse files Browse the repository at this point in the history
  • Loading branch information
davidredborder committed May 31, 2024
1 parent 73d52cb commit f22a469
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 35 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 = node.run_state["sensors_info_all"]
namespaces = get_namespaces()
main_logstash = determine_main_logstash_node()

Expand Down
58 changes: 29 additions & 29 deletions resources/recipes/configure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,16 +200,16 @@

rbmonitor_config "Configure redborder-monitor" do
name node["hostname"]
device_nodes node["redborder"]["sensors_info_all"]["device-sensor"]
flow_nodes node["redborder"]["sensors_info_all"]["flow-sensor"]
device_nodes node.run_state["sensors_info_all"]["device-sensor"]
flow_nodes node.run_state["sensors_info_all"]["flow-sensor"]
managers node["redborder"]["managers_list"]
cluster node["redborder"]["cluster_info"]
hostip node["redborder"]["cluster_info"][name]["ip"]
action (manager_services["redborder-monitor"] ? :add : :remove)
end

rbscanner_config "Configure redborder-scanner" do
scanner_nodes node["redborder"]["sensors_info_all"]["scanner-sensor"]
scanner_nodes node.run_state["sensors_info_all"]["scanner-sensor"]
action (manager_services["redborder-scanner"] ? [:add, :register] : [:remove, :deregister])
end

Expand Down Expand Up @@ -253,10 +253,10 @@
kafka_hosts node["redborder"]["managers_per_services"]["kafka"]
memory node["redborder"]["memory_services"]["http2k"]["memory"]
port node["redborder"]["http2k"]["port"]
proxy_nodes node["redborder"]["sensors_info"]["proxy-sensor"]
ips_nodes node["redborder"]["sensors_info"]["ips-sensor"]
ipsg_nodes node["redborder"]["sensors_info"]["ipsg-sensor"]
ipscp_nodes node["redborder"]["sensors_info"]["ipscp-sensor"]
proxy_nodes node.run_state["sensors_info"]["proxy-sensor"]
ips_nodes node.run_state["sensors_info"]["ips-sensor"]
ipsg_nodes node.run_state["sensors_info"]["ipsg-sensor"]
ipscp_nodes node.run_state["sensors_info"]["ipscp-sensor"]
organizations node["redborder"]["organizations"]
locations_list node["redborder"]["locations"]
action (manager_services["http2k"] ? [:add, :register] : [:remove, :deregister])
Expand All @@ -269,29 +269,29 @@
end

f2k_config "Configure f2k" do
sensors node["redborder"]["sensors_info"]["flow-sensor"]
sensors node.run_state["sensors_info"]["flow-sensor"]
action (manager_services["f2k"] ? [:add, :register] : [:remove, :deregister])
end

pmacct_config "Configure pmacct" do
sensors node["redborder"]["sensors_info"]["flow-sensor"]
sensors node.run_state["sensors_info"]["flow-sensor"]
kafka_hosts node["redborder"]["managers_per_services"]["kafka"]
action (manager_services["pmacct"] ? [:add, :register] : [:remove, :deregister])
end

if node["redborder"]["logstash"]["pipelines"].nil? || node["redborder"]["logstash"]["pipelines"].empty?
if node.run_state["pipelines"].nil? || node.run_state["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"]
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.run_state["pipelines"]
action (manager_services["logstash"] ? [:add, :register] : [:remove, :deregister])
end
end
Expand All @@ -307,29 +307,29 @@
end

rsyslog_config "Configure rsyslog" do
vault_nodes node["redborder"]["sensors_info_all"]["vault-sensor"] + node["redborder"]["sensors_info_all"]["cep-sensor"]
ips_nodes node["redborder"]["sensors_info_all"]["ips-sensor"] + node["redborder"]["sensors_info_all"]["ipsv2-sensor"] + node["redborder"]["sensors_info_all"]["ipscp-sensor"]
vault_nodes node.run_state["sensors_info_all"]["vault-sensor"] + node.run_state["sensors_info_all"]["cep-sensor"]
ips_nodes node.run_state["sensors_info_all"]["ips-sensor"] + node.run_state["sensors_info_all"]["ipsv2-sensor"] + node.run_state["sensors_info_all"]["ipscp-sensor"]
action (manager_services["rsyslog"] ? [:add, :register] : [:remove, :deregister])
end

rbnmsp_config "Configure redborder-nmsp" do
memory node["redborder"]["memory_services"]["redborder-nmsp"]["memory"]
proxy_nodes node["redborder"]["sensors_info_all"]["proxy-sensor"]
flow_nodes node["redborder"]["sensors_info_all"]["flow-sensor"]
proxy_nodes node.run_state["sensors_info_all"]["proxy-sensor"]
flow_nodes node.run_state["sensors_info_all"]["flow-sensor"]
hosts node["redborder"]["zookeeper"]["zk_hosts"]
action (manager_services["redborder-nmsp"] ? [:add, :configure_keys, :register] : [:remove, :deregister])
end

n2klocd_config "Configure n2klocd" do
mse_nodes node["redborder"]["sensors_info_all"]["mse-sensor"]
meraki_nodes node["redborder"]["sensors_info_all"]["meraki-sensor"]
mse_nodes node.run_state["sensors_info_all"]["mse-sensor"]
meraki_nodes node.run_state["sensors_info_all"]["meraki-sensor"]
n2klocd_managers node["redborder"]["managers_per_services"]["n2klocd"]
memory node["redborder"]["memory_services"]["n2klocd"]["memory"]
action (manager_services["n2klocd"] ? [:add, :register] : [:remove, :deregister])
end

rbale_config "Configure redborder-ale" do
ale_nodes node["redborder"]["sensors_info_all"]["ale-sensor"]
ale_nodes node.run_state["sensors_info_all"]["ale-sensor"]
action (node["redborder"]["services"]["redborder-ale"] ? [:add, :register] : [:remove, :deregister])
end

Expand All @@ -338,13 +338,13 @@
end

rb_arubacentral_config "Configure rb-arubacentral" do
arubacentral_nodes node["redborder"]["sensors_info_all"]["arubacentral-sensor"]
flow_nodes node["redborder"]["sensors_info_all"]["flow-sensor"]
arubacentral_nodes node.run_state["sensors_info_all"]["arubacentral-sensor"]
flow_nodes node.run_state["sensors_info_all"]["flow-sensor"]
action (node["redborder"]["services"]["rb-arubacentral"] ? :add : :remove)
end

#freeradius_config "Configure radiusd" do
# flow_nodes node["redborder"]["sensors_info_all"]["flow-sensor"]
# flow_nodes node.run_state["sensors_info_all"]["flow-sensor"]
# action (node["redborder"]["services"]["radiusd"] ? [:config_common, :config_manager, :register] : [:remove, :deregister])
#end

Expand All @@ -353,9 +353,9 @@
end

rbcep_config "Configure redborder-cep" do
flow_nodes node["redborder"]["sensors_info_all"]["flow-sensor"]
vault_nodes node["redborder"]["sensors_info_all"]["vault-sensor"]
ips_nodes node["redborder"]["sensors_info_all"]["ips-sensor"] + node["redborder"]["sensors_info_all"]["ipsv2-sensor"] + node["redborder"]["sensors_info_all"]["ipscp-sensor"]
flow_nodes node.run_state["sensors_info_all"]["flow-sensor"]
vault_nodes node.run_state["sensors_info_all"]["vault-sensor"]
ips_nodes node.run_state["sensors_info_all"]["ips-sensor"] + node.run_state["sensors_info_all"]["ipsv2-sensor"] + node.run_state["sensors_info_all"]["ipscp-sensor"]
action (node["redborder"]["services"]["redborder-cep"] ? [:add, :register] : [:remove, :deregister])
end

Expand Down
10 changes: 5 additions & 5 deletions resources/recipes/prepare_system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,19 @@
node.default["redborder"]["organizations"] = get_orgs() if node["redborder"]["services"]["http2k"]

#get sensors info
node.default["redborder"]["sensors_info"] = get_sensors_info()
node.run_state["sensors_info"] = get_sensors_info()

#get sensors info full info
node.default["redborder"]["sensors_info_all"] = get_sensors_all_info()
node.run_state["sensors_info_all"] = get_sensors_all_info()

#get sensors info of all flow sensors
node.default["redborder"]["all_flow_sensors_info"] = get_all_flow_sensors_info()
node.run_state["all_flow_sensors_info"] = get_all_flow_sensors_info()

#get logstash pipelines
node.default["redborder"]["logstash"]["pipelines"] = get_pipelines()
node.run_state["pipelines"] = get_pipelines()

#get namespaces
node.default["redborder"]["namespaces"] = get_namespaces
node.run_state["namespaces"] = get_namespaces

#get string with all zookeeper hosts and port separated by commas, its needed for multiples services
zk_port = node["redborder"]["zookeeper"]["port"]
Expand Down

0 comments on commit f22a469

Please sign in to comment.