Commit 0325707a authored by Jonathan's avatar Jonathan Committed by GitHub
Browse files

Merge pull request #39 from djjudas21/better_instantiation

Support for virtual modules
parents 48391c81 4cc1acf1
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@
       * [`freeradius::sql`](#freeradiussql)
       * [`freeradius::statusclient`](#freeradiusstatusclient)
       * [`freeradius::template`](#freeradiustemplate)
       * [`freeradius::virtual_module`](#freeradiusvirtual_module)
4. [Limitations - OS compatibility, etc.](#limitations)
5. [Development - Guide for contributing to the module](#development)
6. [Release Notes](#release-notes)
@@ -758,6 +759,30 @@ Provide source to a file with the template item. Specify only one of `source` or

Provide content of template item. Specify only one of `source` or `content`.

#### `freeradius::virtual_module`

Define a virtual module which consists of one or more other modules, for failover or
load-balancing purposes.

##### `submodules`

Provide an array of submodules which will be loaded into this virtual module. Required.

##### `type`

Select the type of virtual module from `redundant`, `load-balance`, `redundant-load-balance`
or `group`. See [virtual modules](http://wiki.freeradius.org/config/Fail-over#virtual-modules)
and [load-balancing](http://wiki.freeradius.org/config/load-balancing) for more details.


```puppet
# Load virtual module myldap
freeradius::virtual_module { 'myldap':
  submodules => ['ldap1', 'ldap2'],
  type       => 'redundant-load-balance',
}
```

## Limitations

This module is targeted at FreeRADIUS 3.x running on CentOS 7. It will not work on
+37 −0
Original line number Diff line number Diff line
# Define a virtual module, made up of others
define freeradius::virtual_module (
  $submodules,
  $ensure = present,
  $type = 'redundant-load-balance',
) {
  $fr_package  = $::freeradius::params::fr_package
  $fr_service  = $::freeradius::params::fr_service
  $fr_basepath = $::freeradius::params::fr_basepath
  $fr_group    = $::freeradius::params::fr_group

  # Valid types of virtual module from
  # http://wiki.freeradius.org/config/load-balancing
  # http://wiki.freeradius.org/config/Fail-over#virtual-modules
  validate_re($type, [
    '^redundant$',
    '^load-balance$',
    '^redundant-load-balance$',
    '^group$',
  ])

  # Make sure $submodules is a non-zero array
  validate_array($submodules)
  if count($submodules) < 1 {
    fail('Must specify at least one $submodule')
  }

  file { "${fr_basepath}/instantiate/${name}":
    ensure  => $ensure,
    mode    => '0640',
    owner   => 'root',
    group   => $fr_group,
    content => template('freeradius/virtual_module.erb'),
    require => [Package[$fr_package], Group[$fr_group]],
    notify  => Service[$fr_service],
  }
}
+1 −0
Original line number Diff line number Diff line
@@ -720,6 +720,7 @@ instantiate {
	#	sql1
	#	sql2
	#}
	$INCLUDE instantiate/
}

######################################################################
+5 −0
Original line number Diff line number Diff line
<%= @type %> <%= @name %> {
<% @submodules.each do |submod| -%>
	<%= submod %>
<% end -%>
}