Commit e79c9bfb 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 155e385d
......@@ -12,6 +12,13 @@ define freeradius::module::ippool (
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,
......
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
# post-auth and accounting sections.
#
......@@ -37,11 +35,7 @@ ippool <%= @name %> {
# The gdbm cache size for the db files. Should
# be equal to the number of ip's available in
# the ip pool
<%- if @cache_size -%>
cache_size = <%= @cache_size %>
<%- else -%>
cache_size = <%= (IPAddr.new @range_stop).to_i() - (IPAddr.new @range_start).to_i() + 1 %>
<%- end -%>
cache_size = <%= @real_cache_size %>
# Helper db index file used in multilink
<%- if @ip_index -%>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment