Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix all current validation errors #149

Merged
merged 3 commits into from
May 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions lib/facter/freeradius_version.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
# Grab the FreeRADIUS version from the output of radiusd -v

module Facter::Util::FreeradiusVersion
class << self
def version_string
# Set path to binary for our platform
dist = Facter.value(:osfamily)
case dist
when /RedHat/
binary = 'radiusd'
when /Debian/
binary = 'freeradius'
else
binary = 'radiusd'
end
binary = case dist
when %r{RedHat}
'radiusd'
when %r{Debian}
'freeradius'
else
'radiusd'
end

Facter::Core::Execution.exec("#{binary} -v")
end
Expand All @@ -23,8 +22,8 @@ def version_string
Facter.add(:freeradius_version) do
setcode do
version_string = Facter::Util::FreeradiusVersion.version_string
if !version_string.nil?
version = version_string.split(/\n/)[0].match(/FreeRADIUS Version (\d+\.\d+\.\d+)/)[1].to_s
unless version_string.nil?
version = version_string.split(%r{\n})[0].match(%r{FreeRADIUS Version (\d+\.\d+\.\d+)})[1].to_s
end
version
end
Expand All @@ -34,8 +33,8 @@ def version_string
Facter.add(:freeradius_maj_version) do
setcode do
version_string = Facter::Util::FreeradiusVersion.version_string
if !version_string.nil?
majver = version_string.split(/\n/)[0].match(/FreeRADIUS Version (\d+)\.\d+\.\d+/)[1].to_s
unless version_string.nil?
majver = version_string.split(%r{\n})[0].match(%r{FreeRADIUS Version (\d+)\.\d+\.\d+})[1].to_s
end
majver
end
Expand Down
7 changes: 6 additions & 1 deletion manifests/blank.pp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
group => $fr_group,
require => [File[$fr_basepath], Package[$fr_package], Group[$fr_group]],
notify => Service[$fr_service],
content => '# This file is intentionally left blank to reduce complexity. Blanking it but leaving it present is safer than deleting it, since the package manager will replace some files if they are deleted, leading to unexpected behaviour!',
content => @(BLANK/L),
# This file is intentionally left blank to reduce complexity. \
Blanking it but leaving it present is safer than deleting it, \
since the package manager will replace some files if they are \
deleted, leading to unexpected behaviour!
|-BLANK
}
}
16 changes: 15 additions & 1 deletion manifests/client.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,21 @@
Optional[Enum['*', 'udp', 'tcp']] $proto = '*',
Freeradius::Boolean $require_message_authenticator = 'no',
Optional[String] $virtual_server = undef,
Optional[Enum['cisco', 'computone', 'livingston', 'juniper', 'max40xx', 'multitech', 'netserver', 'pathras', 'patton', 'portslave', 'tc', 'usrhiper', 'other']] $nastype = undef,
Optional[Enum[
'cisco',
'computone',
'livingston',
'juniper',
'max40xx',
'multitech',
'netserver',
'pathras',
'patton',
'portslave',
'tc',
'usrhiper',
'other',
]] $nastype = undef,
Optional[String] $login = undef,
Optional[String] $password = undef,
Optional[String] $coa_server = undef,
Expand Down
2 changes: 1 addition & 1 deletion manifests/home_server.pp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Configure a home_server for proxy config
define freeradius::home_server (
Enum['udp', 'tcp'] $proto = 'udp',
String $secret,
Enum['udp', 'tcp'] $proto = 'udp',
Enum['none', 'status-server', 'request'] $status_check = 'none',
Enum['auth', 'acct', 'auth+acct', 'coa'] $type = 'auth',
Optional[Integer] $check_interval = undef,
Expand Down
17 changes: 11 additions & 6 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@
"log_destination value (${log_destination}) is not a valid value")

if $control_socket == true {
warning('Use of the control_socket parameter in the freeradius class is deprecated. Please use the freeradius::control_socket class instead.')
warning(@(WARN/L)
Use of the control_socket parameter in the freeradius class is deprecated. \
Please use the freeradius::control_socket class instead.
|-WARN
)
}

# Always restart the service after every module operation
Expand Down Expand Up @@ -324,12 +328,13 @@
# We don't want to create the radiusd user, just add it to the
# wbpriv group if the user needs winbind support. We depend on
# the FreeRADIUS package to be sure that the user has been created
$fr_user_group = $winbind_support ? {
true => $freeradius::fr_wbpriv_user,
default => undef,
}
user { $freeradius::fr_user:
ensure => present,
groups => $winbind_support ? {
true => $freeradius::fr_wbpriv_user,
default => undef,
},
groups => $fr_user_group,
require => Package[$freeradius::fr_package],
}

Expand All @@ -344,7 +349,7 @@
# Syslog rules
if $syslog == true {
rsyslog::snippet { '12-radiusd-log':
content => "if \$programname == \'radiusd\' then ${freeradius::fr_logpath}/radius.log\n\&\~",
content => "if \$programname == \'radiusd\' then ${freeradius::fr_logpath}/radius.log\n\\&\\~",
}
}

Expand Down
7 changes: 7 additions & 0 deletions manifests/module/ippool.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
Integer $maximum_timeout = 0,
Optional[String] $key = undef,
) {
if ($cache_size !~ Undef) {
$real_cache_size = $cache_size
} else {
$real_cache_size = inline_template(@("IPADDRRANGE"/L))
<%- require 'ipaddr' -%><%=(IPAddr.new @range_stop).to_i - (IPAddr.new @range_start).to_i + 1 %>
|-IPADDRRANGE
}

freeradius::module { "ippool_${name}":
ensure => $ensure,
Expand Down
3 changes: 3 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
default => '2',
}
}
default: {
fail("OS ${::operatingsystem} is not supported")
}
}

# Use the FR version fact if defined, otherwise use our best estimate from above
Expand Down
58 changes: 28 additions & 30 deletions spec/classes/freeradius_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
'/etc/raddb/clients.d',
'/etc/raddb/listen.d',
'/etc/raddb/sites-enabled',
'/etc/raddb/instantiate'
'/etc/raddb/instantiate',
].each do |file|
is_expected.to contain_file(file)
.with(
Expand Down Expand Up @@ -93,7 +93,7 @@
.with(
'content' => 'policy {',
'order' => '10',
'target' => '/etc/raddb/policy.conf'
'target' => '/etc/raddb/policy.conf',
)
end

Expand All @@ -102,7 +102,7 @@
.with(
'content' => '}',
'order' => '99',
'target' => '/etc/raddb/policy.conf'
'target' => '/etc/raddb/policy.conf',
)
end

Expand All @@ -123,7 +123,7 @@
.with(
'content' => "# Proxy config\n",
'order' => '05',
'target' => '/etc/raddb/proxy.conf'
'target' => '/etc/raddb/proxy.conf',
)
end

Expand All @@ -143,7 +143,7 @@
is_expected.to contain_concat__fragment('attr-default')
.with(
'order' => '10',
'target' => '/etc/raddb/mods-available/attr_filter'
'target' => '/etc/raddb/mods-available/attr_filter',
)
end

Expand All @@ -163,7 +163,7 @@
.with(
'order' => '10',
'source' => 'puppet:///modules/freeradius/dictionary.header',
'target' => '/etc/raddb/dictionary'
'target' => '/etc/raddb/dictionary',
)
end

Expand All @@ -172,15 +172,15 @@
.with(
'order' => '90',
'source' => 'puppet:///modules/freeradius/dictionary.footer',
'target' => '/etc/raddb/dictionary'
'target' => '/etc/raddb/dictionary',
)
end

it do
is_expected.to contain_package('freeradius')
.with(
'ensure' => 'installed',
'name' => 'freeradius'
'name' => 'freeradius',
)
end

Expand Down Expand Up @@ -226,30 +226,30 @@
it do
is_expected.to contain_group('radiusd')
.with(
'ensure' => 'present',
'ensure' => 'present',
)
.that_requires('Package[freeradius]')
end

it do
is_expected.to contain_freeradius__module('always')
.with( )
.with_preserve(true)
end

it do
is_expected.to contain_freeradius__module('detail')
.with( )
.with_preserve(true)
end

it do
is_expected.to contain_freeradius__module('detail.log')
.with( )
.with_preserve(true)
end

it do
[
'/var/log/radius',
'/var/log/radius/radacct'
'/var/log/radius/radacct',
].each do |file|
is_expected.to contain_file(file)
.with(
Expand All @@ -266,7 +266,7 @@
.with(
'group' => 'radiusd',
'owner' => 'radiusd',
'seltype' => 'radiusd_log_t'
'seltype' => 'radiusd_log_t',
)
.that_requires('Package[freeradius]')
.that_requires('User[radiusd]')
Expand All @@ -283,7 +283,7 @@
'postrotate' => 'kill -HUP `cat /var/run/radiusd/radiusd.pid`',
'rotate' => '7',
'rotate_every' => 'day',
'sharedscripts' => 'true'
'sharedscripts' => 'true',
)
end

Expand All @@ -297,7 +297,7 @@
'postrotate' => 'kill -HUP `cat /var/run/radiusd/radiusd.pid`',
'rotate' => '1',
'rotate_every' => 'week',
'sharedscripts' => 'true'
'sharedscripts' => 'true',
)
end

Expand All @@ -311,18 +311,16 @@
'postrotate' => 'kill -HUP `cat /var/run/radiusd/radiusd.pid`',
'rotate' => '26',
'rotate_every' => 'week',
'sharedscripts' => 'true'
'sharedscripts' => 'true',
)
end

it do
[
'/etc/raddb/certs/dh',
'/etc/raddb/certs/random'
'/etc/raddb/certs/random',
].each do |file|
is_expected.to contain_file(file)
.with(
)
.that_requires('Exec[dh]')
.that_requires('Exec[random]')
end
Expand Down Expand Up @@ -355,7 +353,7 @@
'logoutput' => 'on_failure',
'path' => ['/bin/', '/sbin/', '/usr/bin/', '/usr/sbin/'],
'refreshonly' => 'true',
'returns' => '0'
'returns' => '0',
)
end

Expand Down Expand Up @@ -387,7 +385,7 @@
it do
is_expected.to contain_package('freeradius-mysql')
.with(
'ensure' => 'installed'
'ensure' => 'installed',
)
end
end
Expand All @@ -402,7 +400,7 @@
it do
is_expected.to contain_package('freeradius-postgresql')
.with(
'ensure' => 'installed'
'ensure' => 'installed',
)
end
end
Expand All @@ -417,7 +415,7 @@
it do
is_expected.to contain_package('freeradius-perl')
.with(
'ensure' => 'installed'
'ensure' => 'installed',
)
end
end
Expand All @@ -432,7 +430,7 @@
it do
is_expected.to contain_package('freeradius-utils')
.with(
'ensure' => 'installed'
'ensure' => 'installed',
)
end
end
Expand All @@ -447,7 +445,7 @@
it do
is_expected.to contain_package('freeradius-ldap')
.with(
'ensure' => 'installed'
'ensure' => 'installed',
)
end
end
Expand All @@ -462,7 +460,7 @@
it do
is_expected.to contain_package('freeradius-dhcp')
.with(
'ensure' => 'installed'
'ensure' => 'installed',
)
end
end
Expand All @@ -477,7 +475,7 @@
it do
is_expected.to contain_package('freeradius-krb5')
.with(
'ensure' => 'installed'
'ensure' => 'installed',
)
end
end
Expand All @@ -493,9 +491,9 @@
is_expected.to contain_package('wpa_supplicant')
.with(
'ensure' => 'installed',
'name' => 'wpa_supplicant'
'name' => 'wpa_supplicant',
)
end
end
end

context 'with syslog' do
Expand Down
Loading