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
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -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,
+23 −0
Original line number Diff line number Diff line
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
+1 −7
Original line number Diff line number Diff line
<%- 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 -%>