Skip to content

Commit

Permalink
Merge pull request #53 from redBorder/development
Browse files Browse the repository at this point in the history
Release 2.0.0
  • Loading branch information
manegron authored Oct 19, 2024
2 parents 161e108 + 381c6c7 commit 8574d91
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 21 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
cookbook-rb-ips CHANGELOG
===============

## 2.0.0

- Miguel Negrón
- [4193508] Merge pull request #52 from redBorder/improvement/#18961_service_list_without_chef

## 1.2.0

- Miguel Negrón
Expand Down
25 changes: 10 additions & 15 deletions resources/attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,31 +46,26 @@

# memory
default['redborder']['memory_services'] = {}
default['redborder']['memory_services']['chef-client'] = { 'count': 10, 'memory': 0 }
default['redborder']['memory_services']['snmp'] = { 'count': 5, 'memory': 0, 'max_limit': 10000 }
default['redborder']['memory_services']['barnyard2'] = { 'count': 10, 'memory': 0 }
default['redborder']['memory_services']['redborder-monitor'] = { 'count': 5, 'memory': 0, 'max_limit': 20000 }
default['redborder']['memory_services']['snmp'] = { 'count': 5, 'memory': 0, 'max_limit': 10000 }
default['redborder']['memory_services']['snortd'] = { 'count': 10, 'memory': 0 }
default['redborder']['memory_services']['barnyard2'] = { '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']['barnyard2'] = true
default['redborder']['services']['chef-client'] = true
default['redborder']['services']['chrony'] = true
default['redborder']['services']['redborder-exporter'] = true
default['redborder']['services']['redborder-monitor'] = true
default['redborder']['services']['snmp'] = true
default['redborder']['services']['rsyslog'] = true
default['redborder']['services']['snmp'] = true
default['redborder']['services']['snortd'] = true
default['redborder']['services']['barnyard2'] = true
default['redborder']['services']['clamav'] = true
default['redborder']['services']['chrony'] = true
default['redborder']['services']['redborder-exporter'] = true

default['redborder']['systemdservices']['barnyard2'] = ['barnyard2']
default['redborder']['systemdservices']['chef-client'] = ['chef-client']
default['redborder']['systemdservices']['chrony'] = ['chronyd']
default['redborder']['systemdservices']['redborder-exporter'] = ['rb-exporter']
default['redborder']['systemdservices']['redborder-monitor'] = ['redborder-monitor']
default['redborder']['systemdservices']['snmp'] = ['snmpd']
default['redborder']['systemdservices']['rsyslog'] = ['rsyslog']
default['redborder']['systemdservices']['snmp'] = ['snmpd']
default['redborder']['systemdservices']['snortd'] = ['snortd']
default['redborder']['systemdservices']['barnyard2'] = ['barnyard2']
default['redborder']['systemdservices']['redborder-exporter'] = ['rb-exporter']
default['redborder']['systemdservices']['chrony'] = ['chronyd']
5 changes: 1 addition & 4 deletions resources/libraries/memory_services.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +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) &&
!node['redborder']['excluded_memory_services'].include?(name)
!excluded_services.include?(name)
memory_services_size += mem_s['count']
end

Expand All @@ -24,8 +23,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

Expand Down
2 changes: 1 addition & 1 deletion resources/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
maintainer_email '[email protected]'
license 'AGPL-3.0'
description 'Installs/Configures redborder ips'
version '1.2.0'
version '2.0.0'

depends 'rb-common'
depends 'geoip'
Expand Down
2 changes: 1 addition & 1 deletion resources/recipes/configure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@
end

rb_clamav_config 'Configure ClamAV' do
action(ips_services['clamav'] ? :add : :remove)
action :add
end

rb_chrony_config 'Configure Chrony' do
Expand Down
12 changes: 12 additions & 0 deletions resources/recipes/prepare_system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,15 @@

# node attributes related with memory are changed inside the function to have simplicity using recursivity
memory_services(sysmem_total)

# 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.write('/etc/redborder/services.json', JSON.pretty_generate(service_enablement))

0 comments on commit 8574d91

Please sign in to comment.