Skip to content

Commit

Permalink
Merge pull request #9 from redBorder/development
Browse files Browse the repository at this point in the history
Release 4.0.0
  • Loading branch information
manegron authored Dec 9, 2024
2 parents ce3e04b + 68c7afb commit 204d774
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
cookbook-rb-common CHANGELOG
===============

## 4.0.0

- Miguel Negrón
- [ca06002] Add rb sensor id and role configuration

## 3.0.1

- Miguel Negrón
Expand Down
2 changes: 1 addition & 1 deletion resources/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
maintainer_email '[email protected]'
license 'AGPL-3.0'
description 'Redborder common system settings'
version '3.0.1'
version '4.0.0'
37 changes: 37 additions & 0 deletions resources/providers/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# nofile settings
hard = new_resource.hard
soft = new_resource.soft
sensor_role = new_resource.sensor_role

template '/etc/security/limits.d/10-nofile.conf' do
source '10-nofile.conf.erb'
Expand All @@ -16,4 +17,40 @@
variables(soft: soft,
hard: hard)
end

if sensor_role
sensor_id = node['redborder']['sensor_id']
sensor_id = sensor_id.nil? ? 0 : sensor_id.to_i

template '/etc/rb-id' do
source 'variable.erb'
cookbook 'rb-common'
owner 'root'
group 'root'
mode '600'
retries 2
backup false
variables(variable: sensor_id)
end

template '/etc/chef/role.json' do
source 'role.json.erb'
cookbook 'rb-common'
owner 'root'
group 'root'
mode '644'
retries 2
variables(sensor_role: sensor_role, sensor_id: sensor_id)
end

template '/etc/chef/role-once.json' do
source 'role-once.json.erb'
cookbook 'rb-common'
owner 'root'
group 'root'
mode '644'
retries 2
variables(sensor_role: sensor_role, sensor_id: sensor_id)
end
end
end
1 change: 1 addition & 0 deletions resources/resources/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@

attribute :soft, kind_of: Integer, default: 65535
attribute :hard, kind_of: Integer, default: 65535
attribute :sensor_role, kind_of: String
9 changes: 9 additions & 0 deletions resources/templates/default/role-once.json.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"run_list": [
"role[<%= "#{@sensor_role}" %>]",
"role[<%= @sensor_id>0 ? "rBsensor-#{@sensor_id}" : "{@sensor_role}" %>]"
],
"redborder": {
"force-run-once": true
}
}
9 changes: 9 additions & 0 deletions resources/templates/default/role.json.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"run_list": [
"role[<%= "#{@sensor_role}" %>]",
"role[<%= @sensor_id>0 ? "rBsensor-#{@sensor_id}" : "{@sensor_role}" %>]"
],
"redborder": {
"force-run-once": false
}
}
1 change: 1 addition & 0 deletions resources/templates/default/variable.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%= @variable.nil? ? "" : @variable %>

0 comments on commit 204d774

Please sign in to comment.