From a00eecec256d9424a17ae376f6316e5d1cee5a68 Mon Sep 17 00:00:00 2001 From: Nick Chappell Date: Tue, 18 Nov 2014 21:55:48 -0800 Subject: [PATCH] Add a target_file_ensure parameter to each object type and pass it through to the underlying file resource. The parameter default values are 'file', but having the ensure => parameter of the underlying file type be settable by the user lets people do things like setting target_file_ensure to absent so that they can remove object files via Puppet (instead of manually). refs#7716 : https://dev.icinga.org/issues/7716 --- manifests/object/apply_dependency.pp | 3 ++- .../object/apply_notification_to_host.pp | 3 ++- .../object/apply_notification_to_service.pp | 3 ++- manifests/object/apply_service_to_host.pp | 13 +++++----- manifests/object/checkcommand.pp | 5 ++-- manifests/object/dependency.pp | 3 ++- manifests/object/eventcommand.pp | 25 ++++++++++--------- manifests/object/externalcommandlistener.pp | 3 ++- manifests/object/graphitewriter.pp | 3 ++- manifests/object/host.pp | 3 ++- manifests/object/hostgroup.pp | 3 ++- manifests/object/idomysqlconnection.pp | 3 ++- manifests/object/idopgsqlconnection.pp | 3 ++- manifests/object/livestatuslistener.pp | 4 +-- manifests/object/notification.pp | 3 ++- manifests/object/notificationcommand.pp | 25 ++++++++++--------- manifests/object/perfdatawriter.pp | 3 ++- manifests/object/scheduleddowntime.pp | 3 ++- manifests/object/service.pp | 13 +++++----- manifests/object/servicegroup.pp | 3 ++- manifests/object/statusdatawriter.pp | 4 +-- manifests/object/sysloglogger.pp | 3 ++- manifests/object/timeperiod.pp | 3 ++- manifests/object/user.pp | 3 ++- manifests/object/usergroup.pp | 3 ++- 25 files changed, 83 insertions(+), 60 deletions(-) diff --git a/manifests/object/apply_dependency.pp b/manifests/object/apply_dependency.pp index 4cb2d98..c606ca4 100644 --- a/manifests/object/apply_dependency.pp +++ b/manifests/object/apply_dependency.pp @@ -25,6 +25,7 @@ define icinga2::object::apply_dependency ( $ignore_where = undef, $target_dir = '/etc/icinga2/conf.d', $target_file_name = "${name}.conf", + $target_file_ensure = file, $target_file_owner = 'root', $target_file_group = 'root', $target_file_mode = '0644') { @@ -49,7 +50,7 @@ define icinga2::object::apply_dependency ( validate_re($object_type, ['^Host', '^Service']) file { "${target_dir}/${target_file_name}": - ensure => file, + ensure => $target_file_ensure, owner => $target_file_owner, group => $target_file_group, mode => $target_file_mode, diff --git a/manifests/object/apply_notification_to_host.pp b/manifests/object/apply_notification_to_host.pp index c12db57..5ace072 100644 --- a/manifests/object/apply_notification_to_host.pp +++ b/manifests/object/apply_notification_to_host.pp @@ -26,6 +26,7 @@ define icinga2::object::apply_notification_to_host ( $states = [], $target_dir = '/etc/icinga2/objects/applys', $target_file_name = "${name}.conf", + $target_file_ensure = file, $target_file_owner = 'root', $target_file_group = 'root', $target_file_mode = '0644' @@ -54,7 +55,7 @@ define icinga2::object::apply_notification_to_host ( validate_re($target_file_mode, '^\d{4}$') file { "${target_dir}/${target_file_name}": - ensure => file, + ensure => $target_file_ensure, owner => $target_file_owner, group => $target_file_group, mode => $target_file_mode, diff --git a/manifests/object/apply_notification_to_service.pp b/manifests/object/apply_notification_to_service.pp index ddaed1d..2ddb64e 100644 --- a/manifests/object/apply_notification_to_service.pp +++ b/manifests/object/apply_notification_to_service.pp @@ -27,6 +27,7 @@ define icinga2::object::apply_notification_to_service ( $states = [], $target_dir = '/etc/icinga2/objects/applys', $target_file_name = "${name}.conf", + $target_file_ensure = file, $target_file_owner = 'root', $target_file_group = 'root', $target_file_mode = '0644' @@ -56,7 +57,7 @@ define icinga2::object::apply_notification_to_service ( validate_re($target_file_mode, '^\d{4}$') file { "${target_dir}/${target_file_name}": - ensure => file, + ensure => $target_file_ensure, owner => $target_file_owner, group => $target_file_group, mode => $target_file_mode, diff --git a/manifests/object/apply_service_to_host.pp b/manifests/object/apply_service_to_host.pp index 0e1edcf..12358de 100644 --- a/manifests/object/apply_service_to_host.pp +++ b/manifests/object/apply_service_to_host.pp @@ -37,11 +37,12 @@ define icinga2::object::apply_service_to_host ( $action_url = undef, $icon_image = undef, $icon_image_alt = undef, - $target_dir = '/etc/icinga2/conf.d', - $target_file_name = "${name}.conf", - $target_file_owner = 'root', - $target_file_group = 'root', - $target_file_mode = '0644' + $target_dir = '/etc/icinga2/conf.d', + $target_file_name = "${name}.conf", + $target_file_ensure = file, + $target_file_owner = 'root', + $target_file_group = 'root', + $target_file_mode = '0644' ) { #Do some validation of the class' parameters: @@ -57,7 +58,7 @@ define icinga2::object::apply_service_to_host ( file {"${target_dir}/${target_file_name}": - ensure => file, + ensure => $target_file_ensure, owner => $target_file_owner, group => $target_file_group, mode => $target_file_mode, diff --git a/manifests/object/checkcommand.pp b/manifests/object/checkcommand.pp index d555841..6ca9624 100644 --- a/manifests/object/checkcommand.pp +++ b/manifests/object/checkcommand.pp @@ -25,6 +25,7 @@ define icinga2::object::checkcommand ( $checkcommand_source_file = undef, $checkcommand_file_distribution_method = 'content', $target_file_name = "${name}.conf", + $target_file_ensure = file, $target_file_owner = 'root', $target_file_group = 'root', $target_file_mode = '0644', @@ -53,7 +54,7 @@ define icinga2::object::checkcommand ( if $checkcommand_file_distribution_method == 'content' { file {"${target_dir}/${target_file_name}": - ensure => file, + ensure => $target_file_ensure, owner => $target_file_owner, group => $target_file_group, mode => $target_file_mode, @@ -63,7 +64,7 @@ define icinga2::object::checkcommand ( } elsif $checkcommand_file_distribution_method == 'source' { file {"${target_dir}/${target_file_name}": - ensure => file, + ensure => $target_file_ensure, owner => $target_file_owner, group => $target_file_group, mode => $target_file_mode, diff --git a/manifests/object/dependency.pp b/manifests/object/dependency.pp index cc3f212..555d77d 100644 --- a/manifests/object/dependency.pp +++ b/manifests/object/dependency.pp @@ -22,6 +22,7 @@ define icinga2::object::dependency ( $states = [], $target_dir = '/etc/icinga2/conf.d', $target_file_name = "${name}.conf", + $target_file_ensure = file, $target_file_owner = 'root', $target_file_group = 'root', $target_file_mode = '0644') { @@ -44,7 +45,7 @@ define icinga2::object::dependency ( validate_string($target_file_mode) file { "${target_dir}/${target_file_name}": - ensure => file, + ensure => $target_file_ensure, owner => $target_file_owner, group => $target_file_group, mode => $target_file_mode, diff --git a/manifests/object/eventcommand.pp b/manifests/object/eventcommand.pp index 21dc464..d815d81 100644 --- a/manifests/object/eventcommand.pp +++ b/manifests/object/eventcommand.pp @@ -13,17 +13,18 @@ define icinga2::object::eventcommand ( $object_eventcommandname = $name, $template_to_import = 'plugin-event-command', /* $methods = undef, */ /* Need to get more details about this attribute */ - $command = undef, - $cmd_path = 'PluginDir', - $arguments = {}, - $env = {}, - $vars = {}, - $timeout = undef, - $target_dir = '/etc/icinga2/objects/eventcommands', - $target_file_name = "${name}.conf", - $target_file_owner = 'root', - $target_file_group = 'root', - $target_file_mode = '0644' + $command = undef, + $cmd_path = 'PluginDir', + $arguments = {}, + $env = {}, + $vars = {}, + $timeout = undef, + $target_dir = '/etc/icinga2/objects/eventcommands', + $target_file_name = "${name}.conf", + $target_file_ensure = file, + $target_file_owner = 'root', + $target_file_group = 'root', + $target_file_mode = '0644' ) { #Do some validation of the class' parameters: @@ -45,7 +46,7 @@ define icinga2::object::eventcommand ( file {"${target_dir}/${target_file_name}": - ensure => file, + ensure => $target_file_ensure, owner => $target_file_owner, group => $target_file_group, mode => $target_file_mode, diff --git a/manifests/object/externalcommandlistener.pp b/manifests/object/externalcommandlistener.pp index 993e9a3..7d9f2fd 100644 --- a/manifests/object/externalcommandlistener.pp +++ b/manifests/object/externalcommandlistener.pp @@ -15,6 +15,7 @@ define icinga2::object::externalcommandlistener ( $command_path = undef, $target_dir = '/etc/icinga2/objects/externalcommandlisteners', $target_file_name = "${name}.conf", + $target_file_ensure = file, $target_file_owner = 'root', $target_file_group = 'root', $target_file_mode = '0644' @@ -35,7 +36,7 @@ define icinga2::object::externalcommandlistener ( file {"${target_dir}/${target_file_name}": - ensure => $ensure, + ensure => $target_file_ensure, owner => $target_file_owner, group => $target_file_group, mode => $target_file_mode, diff --git a/manifests/object/graphitewriter.pp b/manifests/object/graphitewriter.pp index e6d3641..cf5629b 100644 --- a/manifests/object/graphitewriter.pp +++ b/manifests/object/graphitewriter.pp @@ -16,6 +16,7 @@ define icinga2::object::graphitewriter ( #since the Graphite writer feature is one that has to be explicitly enabled. $target_dir = '/etc/icinga2/features-available', $target_file_name = "${name}.conf", + $target_file_ensure = file, $target_file_owner = 'root', $target_file_group = 'root', $target_file_mode = '0644' @@ -25,7 +26,7 @@ define icinga2::object::graphitewriter ( validate_string($host) file {"${target_dir}/${target_file_name}": - ensure => file, + ensure => $target_file_ensure, owner => $target_file_owner, group => $target_file_group, mode => $target_file_mode, diff --git a/manifests/object/host.pp b/manifests/object/host.pp index f4d622c..123e360 100644 --- a/manifests/object/host.pp +++ b/manifests/object/host.pp @@ -39,6 +39,7 @@ define icinga2::object::host ( $icon_image_alt = undef, $target_dir = '/etc/icinga2/conf.d', $target_file_name = "${fqdn}.conf", + $target_file_ensure = file, $target_file_owner = 'root', $target_file_group = 'root', $target_file_mode = '0644' @@ -58,7 +59,7 @@ define icinga2::object::host ( validate_string($target_file_mode) file {"${target_dir}/${target_file_name}": - ensure => file, + ensure => $target_file_ensure, owner => $target_file_owner, group => $target_file_group, mode => $target_file_mode, diff --git a/manifests/object/hostgroup.pp b/manifests/object/hostgroup.pp index 371f61c..95937b4 100644 --- a/manifests/object/hostgroup.pp +++ b/manifests/object/hostgroup.pp @@ -16,6 +16,7 @@ define icinga2::object::hostgroup ( $groups = [], $target_dir = '/etc/icinga2/conf.d', $target_file_name = "${name}.conf", + $target_file_ensure = file, $target_file_owner = 'root', $target_file_group = 'root', $target_file_mode = '0644', @@ -35,7 +36,7 @@ define icinga2::object::hostgroup ( validate_string($target_file_mode) file {"${target_dir}/${target_file_name}": - ensure => file, + ensure => $target_file_ensure, owner => $target_file_owner, group => $target_file_group, mode => $target_file_mode, diff --git a/manifests/object/idomysqlconnection.pp b/manifests/object/idomysqlconnection.pp index b6e4d3c..d411e07 100644 --- a/manifests/object/idomysqlconnection.pp +++ b/manifests/object/idomysqlconnection.pp @@ -38,6 +38,7 @@ define icinga2::object::idomysqlconnection ( }, $categories = [], $target_dir = '/etc/icinga2/conf.d', + $target_file_ensure = file, $target_file_name = "${name}.conf", $target_file_owner = 'root', $target_file_group = 'root', @@ -62,7 +63,7 @@ define icinga2::object::idomysqlconnection ( validate_string($target_file_mode) file {"${target_dir}/${target_file_name}": - ensure => file, + ensure => $target_file_ensure, owner => $target_file_owner, group => $target_file_group, mode => $target_file_mode, diff --git a/manifests/object/idopgsqlconnection.pp b/manifests/object/idopgsqlconnection.pp index ce773fd..2a269a3 100644 --- a/manifests/object/idopgsqlconnection.pp +++ b/manifests/object/idopgsqlconnection.pp @@ -39,6 +39,7 @@ define icinga2::object::idopgsqlconnection ( $categories = [], $target_dir = '/etc/icinga2/conf.d', $target_file_name = "${name}.conf", + $target_file_ensure = file, $target_file_owner = 'root', $target_file_group = 'root', $target_file_mode = '0644' @@ -62,7 +63,7 @@ define icinga2::object::idopgsqlconnection ( validate_string($target_file_mode) file {"${target_dir}/${target_file_name}": - ensure => file, + ensure => $target_file_ensure, owner => $target_file_owner, group => $target_file_group, mode => $target_file_mode, diff --git a/manifests/object/livestatuslistener.pp b/manifests/object/livestatuslistener.pp index 63f8201..8ad7980 100644 --- a/manifests/object/livestatuslistener.pp +++ b/manifests/object/livestatuslistener.pp @@ -10,7 +10,6 @@ # define icinga2::object::livestatuslistener ( - $ensure = 'file', $object_livestatuslistenername = $name, $socket_type = undef, $bind_host = undef, @@ -19,6 +18,7 @@ define icinga2::object::livestatuslistener ( $compat_log_path = undef, $target_dir = '/etc/icinga2/objects/livestatuslisteners', $target_file_name = "${name}.conf", + $target_file_ensure = file, $target_file_owner = 'root', $target_file_group = 'root', $target_file_mode = '0644' @@ -51,7 +51,7 @@ define icinga2::object::livestatuslistener ( file {"${target_dir}/${target_file_name}": - ensure => $ensure, + ensure => $target_file_ensure, owner => $target_file_owner, group => $target_file_group, mode => $target_file_mode, diff --git a/manifests/object/notification.pp b/manifests/object/notification.pp index 5f68388..bc0e678 100644 --- a/manifests/object/notification.pp +++ b/manifests/object/notification.pp @@ -24,6 +24,7 @@ define icinga2::object::notification ( $states = [], $target_dir = '/etc/icinga2/objects/notifications', $target_file_name = "${name}.conf", + $target_file_ensure = file, $target_file_owner = 'root', $target_file_group = 'root', $target_file_mode = '0644' @@ -68,7 +69,7 @@ define icinga2::object::notification ( file {"${target_dir}/${target_file_name}": - ensure => file, + ensure => $target_file_ensure, owner => $target_file_owner, group => $target_file_group, mode => $target_file_mode, diff --git a/manifests/object/notificationcommand.pp b/manifests/object/notificationcommand.pp index 928ec5f..57bc252 100644 --- a/manifests/object/notificationcommand.pp +++ b/manifests/object/notificationcommand.pp @@ -13,17 +13,18 @@ define icinga2::object::notificationcommand ( $object_notificationcommandname = $name, $template_to_import = 'plugin-notification-command', /* $methods = undef, */ /* Need to get more details about this attribute */ - $command = undef, - $cmd_path = 'PluginDir', - $arguments = {}, - $env = {}, - $vars = {}, - $timeout = undef, - $target_dir = '/etc/icinga2/objects/notificationcommands', - $target_file_name = "${name}.conf", - $target_file_owner = 'root', - $target_file_group = 'root', - $target_file_mode = '0644' + $command = undef, + $cmd_path = 'PluginDir', + $arguments = {}, + $env = {}, + $vars = {}, + $timeout = undef, + $target_dir = '/etc/icinga2/objects/notificationcommands', + $target_file_name = "${name}.conf", + $target_file_ensure = file, + $target_file_owner = 'root', + $target_file_group = 'root', + $target_file_mode = '0644' ) { #Do some validation of the class' parameters: @@ -45,7 +46,7 @@ define icinga2::object::notificationcommand ( file {"${target_dir}/${target_file_name}": - ensure => file, + ensure => $target_file_ensure, owner => $target_file_owner, group => $target_file_group, mode => $target_file_mode, diff --git a/manifests/object/perfdatawriter.pp b/manifests/object/perfdatawriter.pp index 813f986..4a47d17 100644 --- a/manifests/object/perfdatawriter.pp +++ b/manifests/object/perfdatawriter.pp @@ -21,6 +21,7 @@ define icinga2::object::perfdatawriter ( $rotation_interval = undef, $target_dir = '/etc/icinga2/objects/perfdatawriters', $target_file_name = "${name}.conf", + $target_file_ensure = file, $target_file_owner = 'root', $target_file_group = 'root', $target_file_mode = '0644' @@ -59,7 +60,7 @@ define icinga2::object::perfdatawriter ( file {"${target_dir}/${target_file_name}": - ensure => $ensure, + ensure => $target_file_ensure, owner => $target_file_owner, group => $target_file_group, mode => $target_file_mode, diff --git a/manifests/object/scheduleddowntime.pp b/manifests/object/scheduleddowntime.pp index 65db762..9d0a87b 100644 --- a/manifests/object/scheduleddowntime.pp +++ b/manifests/object/scheduleddowntime.pp @@ -20,6 +20,7 @@ define icinga2::object::scheduleddowntime ( $ranges = {}, $target_dir = '/etc/icinga2/objects/scheduleddowntimes', $target_file_name = "${name}.conf", + $target_file_ensure = file, $target_file_owner = 'root', $target_file_group = 'root', $target_file_mode = '0644' @@ -43,7 +44,7 @@ define icinga2::object::scheduleddowntime ( validate_string($target_file_mode) file {"${target_dir}/${target_file_name}": - ensure => file, + ensure => $target_file_ensure, owner => $target_file_owner, group => $target_file_group, mode => $target_file_mode, diff --git a/manifests/object/service.pp b/manifests/object/service.pp index 6068da0..9cf7a82 100644 --- a/manifests/object/service.pp +++ b/manifests/object/service.pp @@ -36,11 +36,12 @@ define icinga2::object::service ( $action_url = undef, $icon_image = undef, $icon_image_alt = undef, - $target_dir = '/etc/icinga2/conf.d', - $target_file_name = "${name}.conf", - $target_file_owner = 'root', - $target_file_group = 'root', - $target_file_mode = '0644' + $target_dir = '/etc/icinga2/conf.d', + $target_file_name = "${name}.conf", + $target_file_ensure = file, + $target_file_owner = 'root', + $target_file_group = 'root', + $target_file_mode = '0644' ) { #Do some validation of the class' parameters: @@ -57,7 +58,7 @@ define icinga2::object::service ( validate_string($target_file_mode) file {"${target_dir}/${target_file_name}": - ensure => file, + ensure => $target_file_ensure, owner => $target_file_owner, group => $target_file_group, mode => $target_file_mode, diff --git a/manifests/object/servicegroup.pp b/manifests/object/servicegroup.pp index c289862..67c8538 100644 --- a/manifests/object/servicegroup.pp +++ b/manifests/object/servicegroup.pp @@ -16,6 +16,7 @@ define icinga2::object::servicegroup ( $groups = [], $target_dir = '/etc/icinga2/conf.d', $target_file_name = "${name}.conf", + $target_file_ensure = file, $target_file_owner = 'root', $target_file_group = 'root', $target_file_mode = '0644', @@ -35,7 +36,7 @@ define icinga2::object::servicegroup ( validate_string($target_file_mode) file {"${target_dir}/${target_file_name}": - ensure => file, + ensure => $target_file_ensure, owner => $target_file_owner, group => $target_file_group, mode => $target_file_mode, diff --git a/manifests/object/statusdatawriter.pp b/manifests/object/statusdatawriter.pp index 612143f..563e11c 100644 --- a/manifests/object/statusdatawriter.pp +++ b/manifests/object/statusdatawriter.pp @@ -10,13 +10,13 @@ # define icinga2::object::statusdatawriter ( - $ensure = 'file', $object_statusdatawritername = $name, $status_path = undef, $objects_path = undef, $update_interval = undef, $target_dir = '/etc/icinga2/objects/statusdatawriters', $target_file_name = "${name}.conf", + $target_file_ensure = file, $target_file_owner = 'root', $target_file_group = 'root', $target_file_mode = '0644' @@ -43,7 +43,7 @@ define icinga2::object::statusdatawriter ( file {"${target_dir}/${target_file_name}": - ensure => $ensure, + ensure => $target_file_ensure, owner => $target_file_owner, group => $target_file_group, mode => $target_file_mode, diff --git a/manifests/object/sysloglogger.pp b/manifests/object/sysloglogger.pp index bf6dcb0..c33c682 100644 --- a/manifests/object/sysloglogger.pp +++ b/manifests/object/sysloglogger.pp @@ -14,6 +14,7 @@ define icinga2::object::sysloglogger ( $severity = 'warning', $target_dir = '/etc/icinga2/conf.d', $target_file_name = "${name}.conf", + $target_file_ensure = file, $target_file_owner = 'root', $target_file_group = 'root', $target_file_mode = '0644' @@ -29,7 +30,7 @@ define icinga2::object::sysloglogger ( validate_string($target_file_mode) file {"${target_dir}/${target_file_name}": - ensure => file, + ensure => $target_file_ensure, owner => $target_file_owner, group => $target_file_group, mode => $target_file_mode, diff --git a/manifests/object/timeperiod.pp b/manifests/object/timeperiod.pp index a7536e1..1e8d368 100644 --- a/manifests/object/timeperiod.pp +++ b/manifests/object/timeperiod.pp @@ -17,6 +17,7 @@ define icinga2::object::timeperiod ( $ranges = {}, $timeperiod_target_dir = '/etc/icinga2/objects/timeperiods', $timeperiod_target_file_name = "${name}.conf", + $target_file_ensure = file, $target_file_owner = 'root', $target_file_group = 'root', $target_file_mode = '0644', @@ -37,7 +38,7 @@ define icinga2::object::timeperiod ( validate_re($target_file_mode, '^\d{4}$') file {"${timeperiod_target_dir}/${timeperiod_target_file_name}": - ensure => file, + ensure => $target_file_ensure, owner => $target_file_owner, group => $target_file_group, mode => $target_file_mode, diff --git a/manifests/object/user.pp b/manifests/object/user.pp index 90a4c8b..327ea0b 100644 --- a/manifests/object/user.pp +++ b/manifests/object/user.pp @@ -22,6 +22,7 @@ define icinga2::object::user ( $states = [], $target_dir = '/etc/icinga2/conf.d', $target_file_name = "${name}.conf", + $target_file_ensure = file, $target_file_owner = 'root', $target_file_group = 'root', $target_file_mode = '0644' @@ -42,7 +43,7 @@ define icinga2::object::user ( validate_string($target_file_mode) file {"${target_dir}/${target_file_name}": - ensure => file, + ensure => $target_file_ensure, owner => $target_file_owner, group => $target_file_group, mode => $target_file_mode, diff --git a/manifests/object/usergroup.pp b/manifests/object/usergroup.pp index 63e7d1a..3c58096 100644 --- a/manifests/object/usergroup.pp +++ b/manifests/object/usergroup.pp @@ -16,6 +16,7 @@ define icinga2::object::usergroup ( $groups = [], $target_dir = '/etc/icinga2/conf.d', $target_file_name = "${name}.conf", + $target_file_ensure = file, $target_file_owner = 'root', $target_file_group = 'root', $target_file_mode = '0644', @@ -34,7 +35,7 @@ define icinga2::object::usergroup ( validate_string($target_file_mode) file {"${target_dir}/${target_file_name}": - ensure => file, + ensure => $target_file_ensure, owner => $target_file_owner, group => $target_file_group, mode => $target_file_mode,