Skip to content
Snippets Groups Projects
Commit 9d3ad04e authored by Nathan Ward's avatar Nathan Ward
Browse files

Fix an ERB validation error, by moving logic for calculating the ippool cache...

Fix an ERB validation error, by moving logic for calculating the ippool cache size in to puppet, rather than in ERB
parent 01daeff5
No related branches found
No related tags found
No related merge requests found
...@@ -12,6 +12,13 @@ define freeradius::module::ippool ( ...@@ -12,6 +12,13 @@ define freeradius::module::ippool (
Integer $maximum_timeout = 0, Integer $maximum_timeout = 0,
Optional[String] $key = undef, 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}": freeradius::module { "ippool_${name}":
ensure => $ensure, ensure => $ensure,
......
require 'spec_helper'
describe 'freeradius::module::ippool' do
include_context 'redhat_common_dependencies'
let(:title) { 'test' }
let(:params) do
{
range_start: '192.168.0.1',
range_stop: '192.168.0.10',
netmask: '255.255.255.0',
}
end
it do
is_expected.to contain_freeradius__module('ippool_test')
.with_content(%r{^\s+range_start = 192.168.0.1$})
.with_content(%r{^\s+range_stop = 192.168.0.10$})
.with_content(%r{^\s+netmask = 255.255.255.0$})
.with_content(%r{^\s+cache_size = 10$})
end
end
<%- require 'ipaddr' -%>
# Do server side ip pool management. Should be added in # Do server side ip pool management. Should be added in
# post-auth and accounting sections. # post-auth and accounting sections.
# #
...@@ -37,11 +35,7 @@ ippool <%= @name %> { ...@@ -37,11 +35,7 @@ ippool <%= @name %> {
# The gdbm cache size for the db files. Should # The gdbm cache size for the db files. Should
# be equal to the number of ip's available in # be equal to the number of ip's available in
# the ip pool # the ip pool
<%- if @cache_size -%> cache_size = <%= @real_cache_size %>
cache_size = <%= @cache_size %>
<%- else -%>
cache_size = <%= (IPAddr.new @range_stop).to_i() - (IPAddr.new @range_start).to_i() + 1 %>
<%- end -%>
# Helper db index file used in multilink # Helper db index file used in multilink
<%- if @ip_index -%> <%- if @ip_index -%>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment