listen.pp 1.2 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# == Define freeradius::listen
#
define freeradius::listen (
  $ensure          = 'present',
  Freeradius::Listen_type $type            = 'auth',
  $ip          = undef,
  $ip6        = undef,
  Integer $port            = 0,
  $interface       = undef,
  Array $clients         = [],
  Integer $max_connections = 16,
  Integer $lifetime        = 0,
  Integer $idle_timeout    = 30,
) {
  $fr_package  = $::freeradius::params::fr_package
  $fr_service  = $::freeradius::params::fr_service
  $fr_basepath = $::freeradius::params::fr_basepath
  $fr_group    = $::freeradius::params::fr_group

  #
  # Parameters' validation
  if $ip and $ip != '*' and !is_ip_address($ip) {
    fail('ip must be a valid IP address or \'*\'')
  }

  if $ip6 and $ip6 != '::' and !is_ip_address($ip6) {
    fail('ip6 must be a valid IP address or \'::\'')
  }

  if $ip and $ip6 {
    fail('Only of ip and ip6 can be used')
  }

  file { "${fr_basepath}/listen.d/${name}.conf":
    ensure  => $ensure,
    owner   => 'root',
    group   => $fr_group,
    mode    => '0640',
    content => template('freeradius/listen.erb'),
    require => [
      File["${fr_basepath}/listen.d"],
      Group[$fr_group],
    ],
    notify  => Service[$fr_service],
  }
}