Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to hiera and fix spec test setup #202

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions data/Debian-6.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
freeradius::guessversion: '2'
freeradius::basepath: '/etc/freeradius'
freeradius::raddbdir: '${sysconfdir}/freeradius'
4 changes: 4 additions & 0 deletions data/Debian-7.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
freeradius::guessversion: '2'
freeradius::basepath: '/etc/freeradius'
freeradius::raddbdir: '${sysconfdir}/freeradius'
4 changes: 4 additions & 0 deletions data/Debian-8.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
freeradius::guessversion: '2'
freeradius::basepath: '/etc/freeradius'
freeradius::raddbdir: '${sysconfdir}/freeradius'
14 changes: 14 additions & 0 deletions data/Debian.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
freeradius::guessversion: '3'
freeradius::wpa_supplicant_package_name: 'wpasupplicant'
freeradius::service_name: 'freeradius'
freeradius::service_has_status: true
freeradius::basepath: '/etc/freeradius/3.0'
freeradius::raddbdir: '${sysconfdir}/freeradius/3.0'
freeradius::logpath: '/var/log/freeradius'
freeradius::user: 'freerad'
freeradius::group: 'freerad'
freeradius::wbpriv_user: 'winbindd_priv'
freeradius::libdir: '/usr/lib/freeradius'
freeradius::db_dir: '${raddbdir}'
freeradius::radsniff::envfile: '/etc/defaults/radsniff'
2 changes: 2 additions & 0 deletions data/RedHat-5.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
freeradius::guessversion: '2'
2 changes: 2 additions & 0 deletions data/RedHat-6.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
freeradius::guessversion: '2'
2 changes: 2 additions & 0 deletions data/RedHat.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
freeradius::service_has_status: true
4 changes: 4 additions & 0 deletions data/Ubuntu-14.04.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
freeradius::guessversion: '2'
freeradius::basepath: '/etc/freeradius'
freeradius::raddbdir: '${sysconfdir}/freeradius'
4 changes: 4 additions & 0 deletions data/Ubuntu-14.10.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
freeradius::guessversion: '2'
freeradius::basepath: '/etc/freeradius'
freeradius::raddbdir: '${sysconfdir}/freeradius'
4 changes: 4 additions & 0 deletions data/Ubuntu-15.05.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
freeradius::guessversion: '2'
freeradius::basepath: '/etc/freeradius'
freeradius::raddbdir: '${sysconfdir}/freeradius'
4 changes: 4 additions & 0 deletions data/Ubuntu-15.10.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
freeradius::guessversion: '2'
freeradius::basepath: '/etc/freeradius'
freeradius::raddbdir: '${sysconfdir}/freeradius'
9 changes: 9 additions & 0 deletions data/Ubuntu.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
freeradius::service_name: 'radiusd'
freeradius::basepath: '/etc/raddb'
freeradius::raddbdir: '${sysconfdir}/raddb'
freeradius::logpath: '/var/log/radius'
freeradius::user: 'radiusd'
freeradius::group: 'radiusd'
freeradius::libdir: '/usr/lib64/freeradius'
freeradius::db_dir: '${localstatedir}/lib/radiusd'
18 changes: 18 additions & 0 deletions data/common.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
freeradius::guessversion: '3'
freeradius::package_name: 'freeradius'
freeradius::wpa_supplicant_package_name: 'wpa_supplicant'
freeradius::service_name: 'radiusd'
freeradius::service_has_status: false
freeradius::pidfile: "/var/run/%{lookup('freeradius::service_name')}/%{lookup('freeradius::service_name')}.pid"
freeradius::basepath: '/etc/raddb'
freeradius::raddbdir: '${sysconfdir}/raddb'
freeradius::logpath: '/var/log/radius'
freeradius::user: 'radiusd'
freeradius::group: 'radiusd'
freeradius::wbpriv_user: 'wbpriv'
freeradius::libdir: '/usr/lib64/freeradius'
freeradius::db_dir: '${localstatedir}/lib/radiusd'
freeradius::radacctdir: '${logdir}/radacct'
freeradius::radsniff::envfile: '/etc/sysconfig/radsniff'
freeradius::radsniff::pidfile: "/var/run/%{lookup('freeradius::service_name')}/radsniff.pid"
16 changes: 16 additions & 0 deletions hiera.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
version: 5
defaults:
datadir: 'data'
data_hash: 'yaml_data'
hierarchy:
- name: 'Major Version'
path: '%{facts.os.name}-%{facts.os.release.major}.yaml'
- name: 'Distribution Name'
path: '%{facts.os.name}.yaml'
- name: 'OS Family Major Version'
path: '%{facts.os.family}-%{facts.os.release.major}.yaml'
- name: 'OS Family'
path: '%{facts.os.family}.yaml'
- name: 'common'
path: 'common.yaml'
22 changes: 11 additions & 11 deletions manifests/attr.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@
Optional[String] $prefix = 'filter',
Optional[Freeradius::Boolean] $relaxed = undef,
) {
$fr_package = $::freeradius::params::fr_package
$fr_service = $::freeradius::params::fr_service
$fr_basepath = $::freeradius::params::fr_basepath
$fr_group = $::freeradius::params::fr_group
$fr_moduleconfigpath = $::freeradius::params::fr_moduleconfigpath
$fr_modulepath = $::freeradius::params::fr_modulepath
$package_name = $freeradius::package_name
$service_name = $freeradius::service_name
$basepath = $freeradius::basepath
$group = $freeradius::group
$moduleconfigpath = $freeradius::moduleconfigpath
$modulepath = $freeradius::modulepath

# Install the attribute filter snippet
file { "${fr_moduleconfigpath}/attr_filter/${name}":
file { "${moduleconfigpath}/attr_filter/${name}":
ensure => $ensure,
mode => '0640',
owner => 'root',
group => $fr_group,
group => $group,
source => $source,
require => [Package[$fr_package], Group[$fr_group]],
notify => Service[$fr_service],
require => [Package[$package_name], Group[$group]],
notify => Service[$service_name],
}

# Reference all attribute snippets in one file
concat::fragment { "attr-${name}":
target => "${fr_basepath}/mods-available/attr_filter",
target => "${basepath}/mods-available/attr_filter",
content => template('freeradius/attr.erb'),
order => 20,
}
Expand Down
16 changes: 8 additions & 8 deletions manifests/blank.pp
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Blank unneeded config files to reduce complexity
define freeradius::blank {
$fr_package = $::freeradius::params::fr_package
$fr_service = $::freeradius::params::fr_service
$fr_basepath = $::freeradius::params::fr_basepath
$fr_group = $::freeradius::params::fr_group
$package_name = $freeradius::package_name
$service_name = $freeradius::service_name
$basepath = $freeradius::basepath
$group = $freeradius::group

file { "${fr_basepath}/${name}":
file { "${basepath}/${name}":
mode => '0644',
owner => 'root',
group => $fr_group,
require => [File[$fr_basepath], Package[$fr_package], Group[$fr_group]],
notify => Service[$fr_service],
group => $group,
require => [File[$basepath], Package[$package_name], Group[$group]],
notify => Service[$service_name],
content => @(BLANK/L),
# This file is intentionally left blank to reduce complexity. \
Blanking it but leaving it present is safer than deleting it, \
Expand Down
16 changes: 8 additions & 8 deletions manifests/cert.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@
Optional[String] $type = 'key',
Freeradius::Ensure $ensure = present,
) {
$fr_package = $::freeradius::params::fr_package
$fr_service = $::freeradius::params::fr_service
$fr_basepath = $::freeradius::params::fr_basepath
$fr_group = $::freeradius::params::fr_group
$package_name = $freeradius::package_name
$service_name = $freeradius::service_name
$basepath = $freeradius::basepath
$group = $freeradius::group

$permission = $type ? {
'key' => '0640',
'cert' => '0644',
default => '0644',
}

file { "${fr_basepath}/certs/${name}":
file { "${basepath}/certs/${name}":
ensure => $ensure,
mode => $permission,
owner => 'root',
group => $fr_group,
group => $group,
source => $source,
content => $content,
show_diff => false,
require => [File["${fr_basepath}/certs"], Package[$fr_package], Group[$fr_group]],
notify => Service[$fr_service],
require => [File["${basepath}/certs"], Package[$package_name], Group[$group]],
notify => Service[$service_name],
}
}
16 changes: 8 additions & 8 deletions manifests/client.pp
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,19 @@
Variant[Array, Hash, String] $attributes = [],
Optional[String] $huntgroups = undef,
) {
$fr_package = $::freeradius::params::fr_package
$fr_service = $::freeradius::params::fr_service
$fr_basepath = $::freeradius::params::fr_basepath
$fr_group = $::freeradius::params::fr_group
$package_name = $freeradius::package_name
$service_name = $freeradius::service_name
$basepath = $freeradius::basepath
$group = $freeradius::group

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

if ($firewall and $ensure == 'present') {
Expand Down
16 changes: 8 additions & 8 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@
Optional[String] $content = undef,
Freeradius::Ensure $ensure = present,
) {
$fr_package = $::freeradius::params::fr_package
$fr_service = $::freeradius::params::fr_service
$fr_group = $::freeradius::params::fr_group
$fr_moduleconfigpath = $::freeradius::params::fr_moduleconfigpath
$package_name = $freeradius::package_name
$service_name = $freeradius::service_name
$group = $freeradius::group
$moduleconfigpath = $freeradius::moduleconfigpath

file { "${fr_moduleconfigpath}/${name}":
file { "${moduleconfigpath}/${name}":
ensure => $ensure,
mode => '0640',
owner => 'root',
group => $fr_group,
group => $group,
source => $source,
content => $content,
require => [Package[$fr_package], Group[$fr_group]],
notify => Service[$fr_service],
require => [Package[$package_name], Group[$group]],
notify => Service[$service_name],
}
}
4 changes: 2 additions & 2 deletions manifests/control_socket.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
class freeradius::control_socket (
$mode = 'ro',
) {
$fr_user = $::freeradius::params::fr_user
$fr_group = $::freeradius::params::fr_group
$user = $freeradius::user
$group = $freeradius::group

unless $mode in ['ro', 'rw'] {
fail('$mode must be ro or rw')
Expand Down
22 changes: 11 additions & 11 deletions manifests/dictionary.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,36 @@
Optional[Integer] $order = 50,
Freeradius::Ensure $ensure = 'present',
) {
$fr_package = $::freeradius::params::fr_package
$fr_service = $::freeradius::params::fr_service
$fr_basepath = $::freeradius::params::fr_basepath
$fr_group = $::freeradius::params::fr_group
$package_name = $freeradius::package_name
$service_name = $freeradius::service_name
$basepath = $freeradius::basepath
$group = $freeradius::group

if !$source and !$content {
fail('source or content parameter must be provided')
}

# Install dictionary in dictionary.d
file { "${fr_basepath}/dictionary.d/dictionary.${name}":
file { "${basepath}/dictionary.d/dictionary.${name}":
ensure => $ensure,
mode => '0644',
owner => 'root',
group => $fr_group,
group => $group,
source => $source,
content => $content,
require => [File["${fr_basepath}/dictionary.d"], Package[$fr_package], Group[$fr_group]],
notify => Service[$fr_service],
require => [File["${basepath}/dictionary.d"], Package[$package_name], Group[$group]],
notify => Service[$service_name],
}

# Reference policy.d in the global includes file
# If no order priority is given, assume 50

if ($ensure == 'present') {
concat::fragment { "dictionary.${name}":
target => "${fr_basepath}/dictionary",
content => "\$INCLUDE ${fr_basepath}/dictionary.d/dictionary.${name}",
target => "${basepath}/dictionary",
content => "\$INCLUDE ${basepath}/dictionary.d/dictionary.${name}",
order => $order,
require => File["${fr_basepath}/dictionary.d/dictionary.${name}"],
require => File["${basepath}/dictionary.d/dictionary.${name}"],
}
}
}
4 changes: 2 additions & 2 deletions manifests/home_server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
Optional[String] $virtual_server = undef,
Optional[Integer] $zombie_period = undef,
) {
$fr_basepath = $::freeradius::params::fr_basepath
$basepath = $freeradius::basepath

# Configure config fragment for this home server
concat::fragment { "homeserver-${name}":
target => "${fr_basepath}/proxy.conf",
target => "${basepath}/proxy.conf",
content => template('freeradius/home_server.erb'),
order => 10,
}
Expand Down
4 changes: 2 additions & 2 deletions manifests/home_server_pool.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
Optional[String] $virtual_server = undef,
Optional[String] $fallback = undef,
) {
$fr_basepath = $::freeradius::params::fr_basepath
$basepath = $freeradius::basepath

# Configure config fragment for this home server
concat::fragment { "homeserverpool-${name}":
target => "${fr_basepath}/proxy.conf",
target => "${basepath}/proxy.conf",
content => template('freeradius/home_server_pool.erb'),
order => 20,
}
Expand Down
8 changes: 4 additions & 4 deletions manifests/huntgroup.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
Optional[Array[String]] $conditions = [],
Optional[Variant[String, Integer]] $order = 50,
) {
$fr_basepath = $::freeradius::params::fr_basepath
$fr_service = $::freeradius::params::fr_service
$basepath = $freeradius::basepath
$service_name = $freeradius::service_name

concat::fragment { "huntgroup.${title}":
target => "${fr_basepath}/mods-config/preprocess/huntgroups",
target => "${basepath}/mods-config/preprocess/huntgroups",
content => template('freeradius/huntgroup.erb'),
order => $order,
notify => Service[$fr_service],
notify => Service[$service_name],
}
}
Loading