From 0e27a53e5d544c22d17927e7c2b437f5a162c0dc Mon Sep 17 00:00:00 2001 From: manegron Date: Sat, 19 Oct 2024 16:59:15 +0100 Subject: [PATCH 1/3] Remove clamav from service list, simplify out of memory services, sort service list, remove rb-monitor (deprecated) now is redborder-monitor --- resources/attributes/default.rb | 50 ++++++++++++-------------- resources/libraries/memory_services.rb | 6 +--- resources/recipes/configure.rb | 2 +- resources/recipes/prepare_system.rb | 14 ++++++++ 4 files changed, 38 insertions(+), 34 deletions(-) diff --git a/resources/attributes/default.rb b/resources/attributes/default.rb index d323e01..203b56f 100644 --- a/resources/attributes/default.rb +++ b/resources/attributes/default.rb @@ -26,7 +26,6 @@ default['redborder']['memory_services'] = {} default['redborder']['memory_services']['kafka'] = { 'count': 150, 'memory': 0, 'max_limit': 524288 } default['redborder']['memory_services']['zookeeper'] = { 'count': 20, 'memory': 0 } -default['redborder']['memory_services']['chef-client'] = { 'count': 10, 'memory': 0 } default['redborder']['memory_services']['http2k'] = { 'count': 10, 'memory': 0 } default['redborder']['memory_services']['chef-server'] = { 'count': 10, 'memory': 0 } default['redborder']['memory_services']['snmp'] = { 'count': 5, 'memory': 0, 'max_limit': 10000 } @@ -36,44 +35,39 @@ default['redborder']['memory_services']['n2klocd'] = { 'count': 10, 'memory': 0 } default['redborder']['memory_services']['k2http'] = { 'count': 10, 'memory': 0 } -# exclude mem services, setting memory to 0 for each. -default['redborder']['excluded_memory_services'] = ['chef-client'] - default['redborder']['services'] = {} default['redborder']['services']['chef-client'] = true -default['redborder']['services']['kafka'] = true -default['redborder']['services']['zookeeper'] = true -default['redborder']['services']['rb-monitor'] = true -default['redborder']['services']['redborder-monitor'] = true -default['redborder']['services']['redborder-scanner'] = true -default['redborder']['services']['snmp'] = true +default['redborder']['services']['chrony'] = true default['redborder']['services']['f2k'] = true +default['redborder']['services']['k2http'] = true +default['redborder']['services']['kafka'] = true default['redborder']['services']['logstash'] = false -default['redborder']['services']['pmacct'] = true -default['redborder']['services']['rsyslog'] = true -default['redborder']['services']['redborder-nmsp'] = true -default['redborder']['services']['redborder-ale'] = false default['redborder']['services']['n2klocd'] = true +default['redborder']['services']['pmacct'] = true default['redborder']['services']['radiusd'] = false -default['redborder']['services']['k2http'] = true +default['redborder']['services']['redborder-ale'] = false default['redborder']['services']['redborder-exporter'] = true -default['redborder']['services']['clamav'] = true -default['redborder']['services']['chrony'] = true +default['redborder']['services']['redborder-monitor'] = true +default['redborder']['services']['redborder-nmsp'] = true +default['redborder']['services']['redborder-scanner'] = true +default['redborder']['services']['rsyslog'] = true +default['redborder']['services']['snmp'] = true +default['redborder']['services']['zookeeper'] = true default['redborder']['systemdservices']['chef-client'] = ['chef-client'] -default['redborder']['systemdservices']['kafka'] = ['kafka'] -default['redborder']['systemdservices']['zookeeper'] = ['zookeeper'] -default['redborder']['systemdservices']['redborder-monitor'] = ['redborder-monitor'] -default['redborder']['systemdservices']['redborder-scanner'] = ['redborder-scanner'] -default['redborder']['systemdservices']['snmp'] = ['snmpd'] +default['redborder']['systemdservices']['chrony'] = ['chronyd'] default['redborder']['systemdservices']['f2k'] = ['f2k'] +default['redborder']['systemdservices']['k2http'] = ['k2http'] +default['redborder']['systemdservices']['kafka'] = ['kafka'] default['redborder']['systemdservices']['logstash'] = ['logstash'] -default['redborder']['systemdservices']['pmacct'] = ['sfacctd'] -default['redborder']['systemdservices']['rsyslog'] = ['rsyslog'] -default['redborder']['systemdservices']['redborder-nmsp'] = ['redborder-nmsp'] -default['redborder']['systemdservices']['redborder-ale'] = ['redborder-ale'] default['redborder']['systemdservices']['n2klocd'] = ['n2klocd'] +default['redborder']['systemdservices']['pmacct'] = ['sfacctd'] default['redborder']['systemdservices']['radiusd'] = ['radiusd'] -default['redborder']['systemdservices']['k2http'] = ['k2http'] +default['redborder']['systemdservices']['redborder-ale'] = ['redborder-ale'] default['redborder']['systemdservices']['redborder-exporter'] = ['rb-exporter'] -default['redborder']['systemdservices']['chrony'] = ['chronyd'] +default['redborder']['systemdservices']['redborder-monitor'] = ['redborder-monitor'] +default['redborder']['systemdservices']['redborder-nmsp'] = ['redborder-nmsp'] +default['redborder']['systemdservices']['redborder-scanner'] = ['redborder-scanner'] +default['redborder']['systemdservices']['rsyslog'] = ['rsyslog'] +default['redborder']['systemdservices']['snmp'] = ['snmpd'] +default['redborder']['systemdservices']['zookeeper'] = ['zookeeper'] diff --git a/resources/libraries/memory_services.rb b/resources/libraries/memory_services.rb index 82d69a9..4a33032 100644 --- a/resources/libraries/memory_services.rb +++ b/resources/libraries/memory_services.rb @@ -9,9 +9,7 @@ def memory_services(sysmem_total, excluded_services = []) node['redborder']['memory_services'].each do |name, mem_s| if node['redborder']['services'][name] && !excluded_services.include?(name) - unless node['redborder']['excluded_memory_services'].include?(name) - memory_services_size += mem_s['count'] - end + memory_services_size += mem_s['count'] end memory_services_size_total += mem_s['count'] @@ -24,8 +22,6 @@ def memory_services(sysmem_total, excluded_services = []) node['redborder']['memory_services'].each do |name, mem_s| next unless node['redborder']['services'][name] && !excluded_services.include?(name) - next unless !node['redborder']['excluded_memory_services'].include?(name) - # service count memory assigned * system memory / assigned services memory size memory_serv[name] = (mem_s['count'] * sysmem_total / memory_services_size).round diff --git a/resources/recipes/configure.rb b/resources/recipes/configure.rb index 2994db6..403696c 100644 --- a/resources/recipes/configure.rb +++ b/resources/recipes/configure.rb @@ -184,7 +184,7 @@ end rb_clamav_config 'Configure ClamAV' do - action(proxy_services['clamav'] ? :add : :remove) + action :add end rb_chrony_config 'Configure Chrony' do diff --git a/resources/recipes/prepare_system.rb b/resources/recipes/prepare_system.rb index e0e23d1..6a4657b 100644 --- a/resources/recipes/prepare_system.rb +++ b/resources/recipes/prepare_system.rb @@ -80,3 +80,17 @@ retries 2 variables(hosts_entries: hosts_entries) end + +# Build service list for rbcli +services = node['redborder']['services'] || [] +systemd_services = node['redborder']['systemdservices'] || [] +service_enablement = {} + +systemd_services.each do |service_name, systemd_name| + service_enablement[systemd_name.first] = services[service_name] +end + +Chef::Log.info("Saving services enablement into /etc/redborder/services.json") +File.open("/etc/redborder/services.json", "w") do |file| + file.write(JSON.pretty_generate(service_enablement)) +end From a21cae34845a307c7fd29dda770099fb7651fea0 Mon Sep 17 00:00:00 2001 From: manegron Date: Sat, 19 Oct 2024 17:17:01 +0100 Subject: [PATCH 2/3] sort memory_services --- resources/attributes/default.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/resources/attributes/default.rb b/resources/attributes/default.rb index 203b56f..f3444de 100644 --- a/resources/attributes/default.rb +++ b/resources/attributes/default.rb @@ -24,16 +24,16 @@ # memory default['redborder']['memory_services'] = {} -default['redborder']['memory_services']['kafka'] = { 'count': 150, 'memory': 0, 'max_limit': 524288 } -default['redborder']['memory_services']['zookeeper'] = { 'count': 20, 'memory': 0 } -default['redborder']['memory_services']['http2k'] = { 'count': 10, 'memory': 0 } default['redborder']['memory_services']['chef-server'] = { 'count': 10, 'memory': 0 } -default['redborder']['memory_services']['snmp'] = { 'count': 5, 'memory': 0, 'max_limit': 10000 } -default['redborder']['memory_services']['redborder-monitor'] = { 'count': 5, 'memory': 0, 'max_limit': 20000 } default['redborder']['memory_services']['f2k'] = { 'count': 40, 'memory': 0 } -default['redborder']['memory_services']['redborder-nmsp'] = { 'count': 10, 'memory': 0 } -default['redborder']['memory_services']['n2klocd'] = { 'count': 10, 'memory': 0 } +default['redborder']['memory_services']['http2k'] = { 'count': 10, 'memory': 0 } default['redborder']['memory_services']['k2http'] = { 'count': 10, 'memory': 0 } +default['redborder']['memory_services']['kafka'] = { 'count': 150, 'memory': 0, 'max_limit': 524288 } +default['redborder']['memory_services']['n2klocd'] = { 'count': 10, 'memory': 0 } +default['redborder']['memory_services']['redborder-monitor'] = { 'count': 5, 'memory': 0, 'max_limit': 20000 } +default['redborder']['memory_services']['redborder-nmsp'] = { 'count': 10, 'memory': 0 } +default['redborder']['memory_services']['snmp'] = { 'count': 5, 'memory': 0, 'max_limit': 10000 } +default['redborder']['memory_services']['zookeeper'] = { 'count': 20, 'memory': 0 } default['redborder']['services'] = {} default['redborder']['services']['chef-client'] = true From cf55b8203bc43a7c6f5f5036a0ef3672cabb19bd Mon Sep 17 00:00:00 2001 From: manegron Date: Sat, 19 Oct 2024 18:14:16 +0100 Subject: [PATCH 3/3] Pass lint --- resources/recipes/prepare_system.rb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/resources/recipes/prepare_system.rb b/resources/recipes/prepare_system.rb index 6a4657b..5850181 100644 --- a/resources/recipes/prepare_system.rb +++ b/resources/recipes/prepare_system.rb @@ -82,7 +82,7 @@ end # Build service list for rbcli -services = node['redborder']['services'] || [] +services = node['redborder']['services'] || [] systemd_services = node['redborder']['systemdservices'] || [] service_enablement = {} @@ -90,7 +90,5 @@ service_enablement[systemd_name.first] = services[service_name] end -Chef::Log.info("Saving services enablement into /etc/redborder/services.json") -File.open("/etc/redborder/services.json", "w") do |file| - file.write(JSON.pretty_generate(service_enablement)) -end +Chef::Log.info('Saving services enablement into /etc/redborder/services.json') +File.write('/etc/redborder/services.json', JSON.pretty_generate(service_enablement))