Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
CHEF
cookbooks
sys
Commits
dfabec4f
Commit
dfabec4f
authored
Jun 09, 2022
by
Christopher Huhn
Browse files
Add ohai plugin to collect sysctl settings
parent
51ee6452
Changes
4
Hide whitespace changes
Inline
Side-by-side
CHANGELOG.md
View file @
dfabec4f
...
...
@@ -2,6 +2,12 @@
The format is based on
[
Keep a Changelog
](
https://keepachangelog.com/en/1.0.0/
)
.
## [1.67.1] - 2022-06-09
### Added
-
New Ohai plugin
[
`sysctl.rb`
](
files/default/ohai_plugins/sysctl.rb
)
added to collect
information on sysctl settings
## [1.67.0] - 2022-06-08
### Changed
...
...
files/default/ohai_plugins/sysctl.rb
0 → 100644
View file @
dfabec4f
#
# Cookbook Name:: sys
# Ohai plugin to collect sysctl information
#
# Copyright 2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
#
# Authors:
# Christopher Huhn <c.huhn@gsi.de>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
Ohai
.
plugin
(
:Sysctl
)
do
provides
'sysctl'
collect_data
(
:default
)
do
cmd
=
'sysctl -a'
settings
=
shell_out
(
cmd
).
stdout
.
scan
(
/^(.*) = (.*)$/
)
sysctl
Mash
.
new
settings
.
each
do
|
key
,
value
|
# skip zero values to reduce space requirements
next
if
value
==
'0'
# split the sysctl key into components and create s nice data structure
path
=
key
.
split
(
'.'
)
x
=
sysctl
path
[
0
..-
2
].
each
do
|
component
|
x
[
component
]
||=
Mash
.
new
x
=
x
[
component
]
end
x
[
path
.
last
]
=
value
end
end
end
metadata.rb
View file @
dfabec4f
...
...
@@ -16,4 +16,4 @@ supports 'debian'
depends
'line'
,
'< 1.0'
depends
'chef-vault'
version
'1.67.
0
'
version
'1.67.
1
'
test/integration/sys_ohai/serverspec/localhost/ohai_spec.rb
View file @
dfabec4f
...
...
@@ -101,4 +101,22 @@ describe "plugins" do
})
end
end
describe
'sysctl'
do
subject
do
@ohai
.
require_plugin
(
'sysctl'
)
@ohai
.
data
[
'sysctl'
]
end
it
{
should
be_a
(
Mash
)
}
it
do
# TODO: don't hard-code rsa here
# 'anything' or match(...) don't seem to work for a hash key though
should
include
(
kernel:
a_hash_including
(
ostype:
'Linux'
,
version:
anything
))
end
end
end
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment