Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
puppet-freeradius
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Projets publics
puppet-freeradius
Commits
12dab8c2
Commit
12dab8c2
authored
May 14, 2021
by
Nathan Ward
Browse files
Options
Downloads
Patches
Plain Diff
Add radsniff support for Debian-like OSes and specifying envfile and pidfile to support any OS
parent
b2714c80
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
manifests/params.pp
+10
-0
10 additions, 0 deletions
manifests/params.pp
manifests/radsniff.pp
+26
-4
26 additions, 4 deletions
manifests/radsniff.pp
spec/classes/radsniff.rb
+57
-5
57 additions, 5 deletions
spec/classes/radsniff.rb
templates/radsniff.service.erb
+13
-0
13 additions, 0 deletions
templates/radsniff.service.erb
with
106 additions
and
9 deletions
manifests/params.pp
+
10
−
0
View file @
12dab8c2
...
...
@@ -172,4 +172,14 @@ class freeradius::params {
}
$radacctdir
=
"
\$
{logdir}/radacct"
# Default radsniff environment file location
$fr_radsniff_envfile
=
$::osfamily
?
{
'RedHat'
=>
'/etc/sysconfig/radsniff'
,
'Debian'
=>
'/etc/defaults/radsniff'
,
default
=>
undef
,
}
# Default radsniff pid file location
$fr_radsniff_pidfile
=
"/var/run/
${fr_service}
/radsniff.pid"
}
This diff is collapsed.
Click to expand it.
manifests/radsniff.pp
+
26
−
4
View file @
12dab8c2
# @summary configure and run radsniff
#
# @param envfile path to the environment file, used by the systemd unit
# @param options commandline options passed to radsniff when it runs
# @param
class
freeradius::radsniff
(
Optional
[
String
]
$envfile
=
undef
,
String
$options
=
''
,
)
{
Optional
[
String
]
$pidfile
=
undef
,
)
inherits
freeradius::params
{
unless
$::freeradius::utils_support
{
fail
(
'freeradius::radsniff requires freeradius have utils_support enabled'
)
}
unless
$facts
[
'os'
][
'family'
]
==
'RedHat'
{
fail
(
'freeradius::radsniff only supports RedHat like OSes at the moment'
)
# Calculate the envfile to use - specified, then calculated, then error if none
if
$envfile
{
$final_envfile
=
$envfile
}
else
{
if
$freeradius::fr_radsniff_envfile
{
$final_envfile
=
$freeradius::fr_radsniff_envfile
}
else
{
fail
(
'freeradius::radsniff requires envfile to be explicitly set on this OS'
)
}
}
# Calculate the pidfile to use - specified, then calculated, then error if none
if
$pidfile
{
$final_pidfile
=
$pidfile
}
else
{
if
$freeradius::fr_radsniff_pidfile
{
$final_pidfile
=
$freeradius::fr_radsniff_pidfile
}
else
{
fail
(
'freeradius::radsniff requires pidfile to be explicitly set on this OS'
)
}
}
$escaped_cmd
=
$options
.
regsubst
(
'"'
,
'\\\\"'
,
'G'
)
file
{
'/etc/sysconfig/radsniff'
:
file
{
$envfile
:
content
=>
@
(
"SYSCONFIG"
),
RADSNIFF_OPTIONS
=
"
${escaped_cmd}
"
|
SYSCONFIG
...
...
This diff is collapsed.
Click to expand it.
spec/classes/radsniff.rb
+
57
−
5
View file @
12dab8c2
...
...
@@ -13,6 +13,14 @@ describe 'freeradius::radsniff' do
}
end
if
os_facts
[
:osfamily
]
=~
%r{^RedHat|Debian$}
it
do
is_expected
.
to
contain_service
(
'radsniff'
)
.
with_ensure
(
'running'
)
.
with_enable
(
true
)
end
end
case
os_facts
[
:osfamily
]
when
'RedHat'
it
do
...
...
@@ -22,20 +30,64 @@ describe 'freeradius::radsniff' do
.
that_requires
(
'Package[freeradius-utils]'
)
end
it
do
is_expected
.
to
contain_systemd__unit_file
(
'radsniff.service'
)
.
with_content
(
%r{^Pidfile=/var/run/radiusd/radsniff.pid$}
)
.
with_content
(
%r{^EnvironmentFile=/etc/sysconfig/radsniff$}
)
.
with_content
(
%r{^ExecStart=/usr/bin/radsniff -P /var/run/radiusd/radsniff.pid -d /etc/raddb $RADSNIFF_OPTIONS$}
)
.
that_notifies
(
'Service[radsniff]'
)
end
when
'Debian'
it
do
is_expected
.
to
contain_file
(
'/etc/defaults/radsniff'
)
.
with_content
(
%r{RADSNIFF_OPTIONS="radsniff cmd
\\
"line
\\
" options"}
)
.
that_notifies
(
'Service[radsniff]'
)
.
that_requires
(
'Package[freeradius-utils]'
)
end
it
do
is_expected
.
to
contain_systemd__unit_file
(
'radsniff.service'
)
.
with_content
(
%r{^Pidfile=/var/run/freeradius/radsniff.pid$}
)
.
with_content
(
%r{^EnvironmentFile=/etc/defaults/radsniff$}
)
.
with_content
(
%r{^ExecStart=/usr/bin/radsniff -P /var/run/freeradius/radsniff.pid -d /etc/freeradius $RADSNIFF_OPTIONS$}
)
.
that_notifies
(
'Service[radsniff]'
)
end
else
it
do
is_expected
.
to
compile
.
and_raise_error
(
%r{freeradius::radsniff requires envfile to be explicitly set on this OS}
)
is_expected
.
to
compile
.
and_raise_error
(
%r{freeradius::radsniff requires pidfile to be explicitly set on this OS}
)
end
end
context
'with envfile and pidfile set'
do
let
(
:params
)
do
super
().
merge
(
envfile:
'/test/env/file'
,
pidfile:
'/a/pid/file'
,
)
end
if
os_facts
[
:osfamily
]
!~
%r{^RedHat|Debian$}
it
do
is_expected
.
to
contain_service
(
'radsniff'
)
.
with_ensure
(
'running'
)
.
with_enable
(
true
)
end
end
it
do
is_expected
.
to
contain_
systemd__unit_file
(
'radsniff.servic
e'
)
.
with_
source
(
'puppet:///modules/freeradius/radsniff.service'
)
is_expected
.
to
contain_
file
(
'/test/env/fil
e'
)
.
with_
content
(
%r{RADSNIFF_OPTIONS="radsniff cmd
\\
"line
\\
" options"}
)
.
that_notifies
(
'Service[radsniff]'
)
.
that_requires
(
'Package[freeradius-utils]'
)
end
else
it
do
is_expected
.
to
compile
.
and_raise_error
(
%r{radsniff only supports RedHat}
)
is_expected
.
to
contain_systemd__unit_file
(
'radsniff.service'
)
.
with_content
(
%r{^Pidfile=/a/pid/file$}
)
.
with_content
(
%r{^EnvironmentFile=/test/env/file$}
)
.
with_content
(
%r{^ExecStart=/usr/bin/radsniff -P /a/pid/file -d /etc/freeradius $RADSNIFF_OPTIONS$}
)
.
that_notifies
(
'Service[radsniff]'
)
end
end
end
...
...
This diff is collapsed.
Click to expand it.
fil
es/radsniff.service
→
templat
es/radsniff.service
.erb
+
13
−
0
View file @
12dab8c2
...
...
@@ -5,9 +5,9 @@ After=radiusd.target
[Service]
Type=forking
P
IDF
ile
=
/var/run/
radius
d/
radsniff
.pid
EnvironmentFile
=
/etc/sysconfig/radsniff
ExecStart
=
/usr/bin/radsniff -P
/var/run/
radius
d/
radsniff
.
pid
-d /etc/raddb
$RADSNIFF_OPTIONS
P
idf
ile=
<%=
scope
[
'::free
radius
::
radsniff
::final_pidfile'
]
%>
EnvironmentFile=
<%=
scope
[
'::freeradius::radsniff::final_envpath'
]
%>
ExecStart=/usr/bin/radsniff -P
<%=
scope
[
'::free
radius
::
radsniff
::
pid
path'
]
%>
-d
<%=
scope
[
'::freeradius::radsniff::fr_basepath'
]
%>
$RADSNIFF_OPTIONS
[Install]
WantedBy=multi-user.target
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment