Commit ceff11cd authored by Jonathan Gazeley's avatar Jonathan Gazeley
Browse files

Add 'ensure' parameter to all defined types

parent 06a82abc
# Install FreeRADIUS config snippets
define freeradius::attr ($source) {
define freeradius::attr (
$source,
$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
file { "${fr_basepath}/attr.d/${name}":
ensure => $ensure,
mode => '0640',
owner => 'root',
group => $fr_group,
......
......@@ -2,6 +2,7 @@
define freeradius::cert (
$source,
$type = 'key',
$ensure = present,
) {
$fr_package = $::freeradius::params::fr_package
$fr_service = $::freeradius::params::fr_service
......@@ -9,6 +10,7 @@ define freeradius::cert (
$fr_group = $::freeradius::params::fr_group
file { "${fr_basepath}/certs/${name}":
ensure => $ensure,
mode => $type ? {
'key' => '0640',
'cert' => '0644',
......
......@@ -11,6 +11,7 @@ define freeradius::client (
$port = undef,
$srcip = undef,
$firewall = false,
$ensure = present,
) {
$fr_package = $::freeradius::params::fr_package
$fr_service = $::freeradius::params::fr_service
......@@ -18,6 +19,7 @@ define freeradius::client (
$fr_group = $::freeradius::params::fr_group
file { "${fr_basepath}/clients.d/${shortname}.conf":
ensure => $ensure,
mode => '0640',
owner => 'root',
group => $fr_group,
......@@ -26,7 +28,7 @@ define freeradius::client (
notify => Service[$fr_service],
}
if $firewall {
if ($firewall and $ensure == 'present') {
if $port {
if $ip {
firewall { "100-${shortname}-${port}-v4":
......
# Install FreeRADIUS config snippets
define freeradius::config ($source) {
define freeradius::config (
$source,
$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
file { "${fr_basepath}/conf.d/${name}":
ensure => $ensure,
mode => '0640',
owner => 'root',
group => $fr_group,
......
# Install FreeRADIUS custom dictionaries
define freeradius::dictionary ($source, $order = 50) {
define freeradius::dictionary (
$source,
$order = 50,
$ensure = present,
) {
$fr_package = $::freeradius::params::fr_package
$fr_service = $::freeradius::params::fr_service
$fr_basepath = $::freeradius::params::fr_basepath
......@@ -7,6 +11,7 @@ define freeradius::dictionary ($source, $order = 50) {
# Install dictionary in dictionary.d
file { "${fr_basepath}/dictionary.d/dictionary.${name}":
ensure => $ensure,
mode => '0644',
owner => 'root',
group => $fr_group,
......@@ -17,10 +22,13 @@ define freeradius::dictionary ($source, $order = 50) {
# Reference policy.d in the global includes file
# If no order priority is given, assume 50
concat::fragment { "dictionary.${name}":
target => "${fr_basepath}/dictionary",
content => "\$INCLUDE ${fr_basepath}/dictionary.d/dictionary.${name}\n",
order => $order,
require => File["${fr_basepath}/dictionary.d/dictionary.${name}"],
if ($ensure == 'present') {
concat::fragment { "dictionary.${name}":
target => "${fr_basepath}/dictionary",
content => "\$INCLUDE ${fr_basepath}/dictionary.d/dictionary.${name}\n",
order => $order,
require => File["${fr_basepath}/dictionary.d/dictionary.${name}"],
}
}
}
# Instantiate a module in global config
define freeradius::instantiate {
define freeradius::instantiate (
$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
file { "${fr_basepath}/instantiate/${name}":
ensure => $ensure,
mode => '0640',
owner => 'root',
group => $fr_group,
......
# Install FreeRADIUS modules
define freeradius::module ($source) {
define freeradius::module (
$source,
$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
file { "${fr_basepath}/modules/${name}":
ensure => $ensure,
mode => '0640',
owner => 'root',
group => $fr_group,
......
# Install FreeRADIUS policies
define freeradius::policy ($source, $order = 50) {
define freeradius::policy (
$source,
$order = 50,
$ensure = present,
) {
$fr_package = $::freeradius::params::fr_package
$fr_service = $::freeradius::params::fr_service
$fr_basepath = $::freeradius::params::fr_basepath
......@@ -7,6 +11,7 @@ define freeradius::policy ($source, $order = 50) {
# Install policy in policy.d
file { "${fr_basepath}/policy.d/${name}":
ensure => $ensure,
mode => '0644',
owner => 'root',
group => $fr_group,
......@@ -17,11 +22,12 @@ define freeradius::policy ($source, $order = 50) {
# Reference policy.d in the global includes file
# If no order priority is given, assume 50
concat::fragment { "policy-${name}":
target => "${fr_basepath}/policy.conf",
content => "\t\$INCLUDE ${fr_basepath}/policy.d/${name}\n",
order => $order,
require => File["${fr_basepath}/policy.d/${name}"],
if ($ensure == 'present') {
concat::fragment { "policy-${name}":
target => "${fr_basepath}/policy.conf",
content => "\t\$INCLUDE ${fr_basepath}/policy.d/${name}\n",
order => $order,
require => File["${fr_basepath}/policy.d/${name}"],
}
}
}
# Install FreeRADIUS helper scripts
define freeradius::script ($source) {
define freeradius::script (
$source,
$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
file { "${fr_basepath}/scripts/${name}":
ensure => $ensure,
mode => '0750',
owner => 'root',
group => $fr_group,
......
# Install FreeRADIUS virtual servers (sites)
define freeradius::site ($source = undef, $content = undef,) {
define freeradius::site (
$source = undef,
$content = undef,
$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
file { "${fr_basepath}/sites-enabled/${name}":
ensure => $ensure,
mode => '0640',
owner => 'root',
group => $fr_group,
......
......@@ -7,6 +7,7 @@ define freeradius::sql (
$radius_db = 'radius',
$num_sql_socks = '${thread[pool].max_servers}',
$query_file = 'sql/${database}/dialup.conf',
$ensure = present,
) {
$fr_package = $::freeradius::params::fr_package
$fr_service = $::freeradius::params::fr_service
......@@ -20,6 +21,7 @@ define freeradius::sql (
# Generate a module config, based on sql.conf
file { "${fr_basepath}/modules/${name}":
ensure => $ensure,
mode => '0640',
owner => 'root',
group => $fr_group,
......
# Install FreeRADIUS clients (WISMs or testing servers)
define freeradius::statusclient ($secret, $ip = undef, $ip6 = undef, $port = undef, $shortname = $name, $netmask = undef,) {
define freeradius::statusclient (
$secret,
$ip = undef,
$ip6 = undef,
$port = undef,
$shortname = $name,
$netmask = undef,
$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
file { "${fr_basepath}/statusclients.d/${name}.conf":
ensure => $ensure,
mode => '0640',
owner => 'root',
group => $fr_group,
......
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