From f22a469e5e1e6b91e00567c48f367473718d008e Mon Sep 17 00:00:00 2001 From: David Vanhoucke Date: Fri, 31 May 2024 14:33:34 +0100 Subject: [PATCH] add temporary variables in node.run_state --- resources/libraries/get_pipelines.rb | 2 +- resources/recipes/configure.rb | 58 ++++++++++++++-------------- resources/recipes/prepare_system.rb | 10 ++--- 3 files changed, 35 insertions(+), 35 deletions(-) diff --git a/resources/libraries/get_pipelines.rb b/resources/libraries/get_pipelines.rb index c84920d6..f9fbeaa3 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 = node.run_state["sensors_info_all"] namespaces = get_namespaces() main_logstash = determine_main_logstash_node() diff --git a/resources/recipes/configure.rb b/resources/recipes/configure.rb index 617840fc..8de0dc24 100644 --- a/resources/recipes/configure.rb +++ b/resources/recipes/configure.rb @@ -200,8 +200,8 @@ 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"] @@ -209,7 +209,7 @@ 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 @@ -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]) @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/resources/recipes/prepare_system.rb b/resources/recipes/prepare_system.rb index 0f97e046..7551a7d6 100644 --- a/resources/recipes/prepare_system.rb +++ b/resources/recipes/prepare_system.rb @@ -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"]