remove settings when value is not set

This commit is contained in:
Timo Goebel 2015-04-28 16:23:20 +02:00 committed by Markus Frosch
parent 9425df2002
commit 2cb4e0f46d

View file

@ -2,10 +2,10 @@
# #
define icingaweb2::config::roles ( define icingaweb2::config::roles (
$role_groups = undef, $role_groups = undef,
$role_host_filter = absent, $role_host_filter = undef,
$role_name = $title, $role_name = $title,
$role_permissions = undef, $role_permissions = undef,
$role_service_filter = absent, $role_service_filter = undef,
$role_users = undef, $role_users = undef,
) { ) {
Ini_Setting { Ini_Setting {
@ -14,34 +14,75 @@ define icingaweb2::config::roles (
path => "${::icingaweb2::config_dir}/roles.ini", path => "${::icingaweb2::config_dir}/roles.ini",
} }
if $role_users {
ini_setting { "icingaweb2 roles ${title} users": ini_setting { "icingaweb2 roles ${title} users":
section => $role_name, section => $role_name,
setting => 'users', setting => 'users',
value => "\"${role_users}\"", value => "\"${role_users}\"",
} }
} else {
ini_setting { "icingaweb2 roles ${title} users":
ensure => absent,
section => $role_name,
setting => 'users',
}
}
if $role_groups {
ini_setting { "icingaweb2 roles ${title} groups": ini_setting { "icingaweb2 roles ${title} groups":
section => $role_name, section => $role_name,
setting => 'groups', setting => 'groups',
value => "\"${role_groups}\"", value => "\"${role_groups}\"",
} }
} else {
ini_setting { "icingaweb2 roles ${title} groups":
ensure => absent,
section => $role_name,
setting => 'groups',
}
}
if $role_permissions {
ini_setting { "icingaweb2 roles ${title} permissions": ini_setting { "icingaweb2 roles ${title} permissions":
section => $role_name, section => $role_name,
setting => 'permissions', setting => 'permissions',
value => "\"${role_permissions}\"", value => "\"${role_permissions}\"",
} }
} else {
ini_setting { "icingaweb2 roles ${title} permissions":
ensure => absent,
section => $role_name,
setting => 'permissions',
}
}
if $role_host_filter {
ini_setting { "icingaweb2 roles ${title} host filter": ini_setting { "icingaweb2 roles ${title} host filter":
section => $role_name, section => $role_name,
setting => 'monitoring/hosts/filter', setting => 'monitoring/hosts/filter',
value => "\"${role_host_filter}\"", value => "\"${role_host_filter}\"",
} }
} else {
ini_setting { "icingaweb2 roles ${title} host filter":
ensure => absent,
section => $role_name,
setting => 'monitoring/hosts/filter',
}
}
if $role_service_filter {
ini_setting { "icingaweb2 roles ${title} service filter": ini_setting { "icingaweb2 roles ${title} service filter":
section => $role_name, section => $role_name,
setting => 'monitoring/services/filter', setting => 'monitoring/services/filter',
value => "\"${role_service_filter}\"", value => "\"${role_service_filter}\"",
} }
} else {
ini_setting { "icingaweb2 roles ${title} service filter":
ensure => absent,
section => $role_name,
setting => 'monitoring/services/filter',
}
}
} }