Commit dd326e2a authored by Angel L. Mateo's avatar Angel L. Mateo
Browse files

Add freeradius::module::files

to configure files module
parent 8bf2338c
# == Define freeradius::module::files
#
# Create e file module configuration for FreeRADIUS
#
define freeradius::module::files (
$ensure = 'present',
String $moddir = "\${modconfdir}/\${.:instance}",
Optional[String] $key = undef,
String $filename = "\${moddir}/authorize",
Optional[String] $usersfile = undef,
String $acctusersfile = "\${moddir}/accounting",
String $preproxy_usersfile = "\${moddir}/pre-proxy",
Array[Hash] $users = [],
Optional[String] $source = undef,
Optional[String] $content = undef,
) {
$fr_moduleconfigpath = $::freeradius::params::fr_moduleconfigpath
$fr_group = $::freeradius::params::fr_group
$fr_service = $::freeradius::params::fr_service
$manage_content = $content ? {
undef => template('freeradius/users.erb'),
default => $content,
}
$manage_dir = $ensure ? {
'present' => 'directory',
default => 'absent',
}
if $filename =~ /^\$\{moddir\}\/(.+)$/ {
$userspath = "${fr_moduleconfigpath}/${name}/${1}"
$usersdir = "${fr_moduleconfigpath}/${name}"
} else {
$userspath = $filename
$usersdir = dirname($filename)
}
freeradius::module {$name:
ensure => $ensure,
content => template('freeradius/files.erb'),
}
file {$usersdir:
ensure => $manage_dir,
owner => 'root',
group => $fr_group,
mode => '0750',
require => Freeradius::Module[$name],
}
file {$userspath:
ensure => $ensure,
owner => 'root',
group => $fr_group,
mode => '0640',
source => $source,
content => $manage_content,
require => File[$usersdir],
notify => Service[$fr_service],
}
}
# This file is managed by Puppet. DO NOT EDIT.
#
# Livingston-style 'users' file
#
# See "man users" for more information.
#
<%- if @name == 'default' -%>
files {
<%- else -%>
files <%= @name %> {
<%- end -%>
# Search for files in a subdirectory of mods-config which
# matches this instance of the files module.
moddir = <%= @moddir %>
# The default key attribute to use for matches. The content
# of this attribute is used to match the "name" of the
# entry.
#key = "%{%{Stripped-User-Name}:-%{User-Name}}"
<%- if @key -%>
key = "<%= @key %>"
<%- end -%>
# The old "users" style file is now located here.
filename = <%= @filename %>
# This is accepted for backwards compatibility
# It will be removed in a future release.
# usersfile = ${moddir}/authorize
<%- if @usersfile -%>
usersfile = <%= @usersfile %>
<%- end -%>
# These are accepted for backwards compatibility.
# They will be renamed in a future release.
acctusersfile = ${moddir}/accounting
preproxy_usersfile = ${moddir}/pre-proxy
}
# This file is automatically managed by puppet
#
<%- @users.each do |user| -%>
<%- if user.is_a?(Hash) -%>
<%- checks = user['check_items'] ? user['check_items'] : [] -%>
<%- replies = user['reply_items'] ? user['reply_items'] : [] -%>
<%= user['login'] %> <%= checks.join(", ") %>
<%= "\t" + replies.join(",\n\t") %>
<%- else -%>
<%= user %>
<%- end -%>
<%- end -%>
Supports Markdown
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