diff --git a/manifests/object/apply_dependency.pp b/manifests/object/apply_dependency.pp index c606ca4..f965597 100644 --- a/manifests/object/apply_dependency.pp +++ b/manifests/object/apply_dependency.pp @@ -28,7 +28,9 @@ define icinga2::object::apply_dependency ( $target_file_ensure = file, $target_file_owner = 'root', $target_file_group = 'root', - $target_file_mode = '0644') { + $target_file_mode = '0644', + $refresh_icinga2_service = true + ) { # Do some validation of the class' parameters: validate_string($object_name) validate_string($display_name) @@ -46,16 +48,35 @@ define icinga2::object::apply_dependency ( validate_string($target_file_owner) validate_string($target_file_group) validate_string($target_file_mode) + validate_bool($refresh_icinga2_service) validate_re($object_type, ['^Host', '^Service']) - file { "${target_dir}/${target_file_name}": - ensure => $target_file_ensure, - owner => $target_file_owner, - group => $target_file_group, - mode => $target_file_mode, - content => template('icinga2/object_apply_dependency.conf.erb'), - notify => Service['icinga2'], + #If the refresh_icinga2_service parameter is set to true... + if $refresh_icinga2_service == true { + + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_apply_dependency.conf.erb'), + #...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file... + notify => Service['icinga2'], + } + + } + #...otherwise, use the same file resource but without a notify => parameter: + else { + + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_apply_dependency.conf.erb'), + } + } -} +} \ No newline at end of file diff --git a/manifests/object/apply_notification_to_host.pp b/manifests/object/apply_notification_to_host.pp index 5ace072..56dc001 100644 --- a/manifests/object/apply_notification_to_host.pp +++ b/manifests/object/apply_notification_to_host.pp @@ -29,7 +29,8 @@ define icinga2::object::apply_notification_to_host ( $target_file_ensure = file, $target_file_owner = 'root', $target_file_group = 'root', - $target_file_mode = '0644' + $target_file_mode = '0644', + $refresh_icinga2_service = true ) { #Do some validation of the class' parameters: @@ -53,13 +54,33 @@ define icinga2::object::apply_notification_to_host ( validate_string($target_file_owner) validate_string($target_file_group) validate_re($target_file_mode, '^\d{4}$') + validate_bool($refresh_icinga2_service) + + #If the refresh_icinga2_service parameter is set to true... + if $refresh_icinga2_service == true { + + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_apply_notification_to_host.conf.erb'), + #...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file... + notify => Service['icinga2'], + } - file { "${target_dir}/${target_file_name}": - ensure => $target_file_ensure, - owner => $target_file_owner, - group => $target_file_group, - mode => $target_file_mode, - content => template('icinga2/object_apply_notification_to_host.conf.erb'), - notify => Service['icinga2'], } + #...otherwise, use the same file resource but without a notify => parameter: + else { + + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_apply_notification_to_host.conf.erb'), + } + + } + } diff --git a/manifests/object/apply_notification_to_service.pp b/manifests/object/apply_notification_to_service.pp index 2ddb64e..bda9a16 100644 --- a/manifests/object/apply_notification_to_service.pp +++ b/manifests/object/apply_notification_to_service.pp @@ -30,7 +30,8 @@ define icinga2::object::apply_notification_to_service ( $target_file_ensure = file, $target_file_owner = 'root', $target_file_group = 'root', - $target_file_mode = '0644' + $target_file_mode = '0644', + $refresh_icinga2_service = true ) { #Do some validation of the class' parameters: @@ -55,13 +56,33 @@ define icinga2::object::apply_notification_to_service ( validate_string($target_file_owner) validate_string($target_file_group) validate_re($target_file_mode, '^\d{4}$') + validate_bool($refresh_icinga2_service) + + #If the refresh_icinga2_service parameter is set to true... + if $refresh_icinga2_service == true { + + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_apply_notification_to_service.conf.erb'), + #...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file... + notify => Service['icinga2'], + } - file { "${target_dir}/${target_file_name}": - ensure => $target_file_ensure, - owner => $target_file_owner, - group => $target_file_group, - mode => $target_file_mode, - content => template('icinga2/object_apply_notification_to_service.conf.erb'), - notify => Service['icinga2'], } + #...otherwise, use the same file resource but without a notify => parameter: + else { + + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_apply_notification_to_service.conf.erb'), + } + + } + } diff --git a/manifests/object/apply_service_to_host.pp b/manifests/object/apply_service_to_host.pp index 81d811a..6b86c6f 100644 --- a/manifests/object/apply_service_to_host.pp +++ b/manifests/object/apply_service_to_host.pp @@ -43,7 +43,8 @@ define icinga2::object::apply_service_to_host ( $target_file_ensure = file, $target_file_owner = 'root', $target_file_group = 'root', - $target_file_mode = '0644' + $target_file_mode = '0644', + $refresh_icinga2_service = true ) { #Do some validation of the class' parameters: @@ -56,15 +57,33 @@ define icinga2::object::apply_service_to_host ( validate_string($target_file_owner) validate_string($target_file_group) validate_string($target_file_mode) + validate_bool($refresh_icinga2_service) + #If the refresh_icinga2_service parameter is set to true... + if $refresh_icinga2_service == true { - file {"${target_dir}/${target_file_name}": - ensure => $target_file_ensure, - owner => $target_file_owner, - group => $target_file_group, - mode => $target_file_mode, - content => template('icinga2/object_apply_service_to_host.conf.erb'), - notify => Service['icinga2'], + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_apply_service_to_host.conf.erb'), + #...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file... + notify => Service['icinga2'], + } + + } + #...otherwise, use the same file resource but without a notify => parameter: + else { + + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_apply_service_to_host.conf.erb'), + } + } } diff --git a/manifests/object/checkcommand.pp b/manifests/object/checkcommand.pp index 6ca9624..bf5ea50 100644 --- a/manifests/object/checkcommand.pp +++ b/manifests/object/checkcommand.pp @@ -29,6 +29,7 @@ define icinga2::object::checkcommand ( $target_file_owner = 'root', $target_file_group = 'root', $target_file_mode = '0644', + $refresh_icinga2_service = true ) { #Do some validation of the class' parameters: @@ -50,31 +51,65 @@ define icinga2::object::checkcommand ( validate_string($target_file_owner) validate_string($target_file_group) validate_re($target_file_mode, '^\d{4}$') + validate_bool($refresh_icinga2_service) - if $checkcommand_file_distribution_method == 'content' { - file {"${target_dir}/${target_file_name}": - ensure => $target_file_ensure, - owner => $target_file_owner, - group => $target_file_group, - mode => $target_file_mode, - content => template("${checkcommand_template_module}/${checkcommand_template}"), - notify => Service['icinga2'], - } - } - elsif $checkcommand_file_distribution_method == 'source' { - file {"${target_dir}/${target_file_name}": - ensure => $target_file_ensure, - owner => $target_file_owner, - group => $target_file_group, - mode => $target_file_mode, - source => $checkcommand_source_file, - notify => Service['icinga2'], + #If the refresh_icinga2_service parameter is set to true... + if $refresh_icinga2_service == true { + if $checkcommand_file_distribution_method == 'content' { + file {"${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template("${checkcommand_template_module}/${checkcommand_template}"), + notify => Service['icinga2'], + } + } + elsif $checkcommand_file_distribution_method == 'source' { + file {"${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + source => $checkcommand_source_file, + notify => Service['icinga2'], + } + } + else { + notify {'Missing/Incorrect File Distribution Method': + message => 'The parameter checkcommand_file_distribution_method is missing or incorrect. Please set content or source', + } } } + + #...otherwise, use the same file resource but without a notify => parameter: else { - notify {'Missing/Incorrect File Distribution Method': - message => 'The parameter checkcommand_file_distribution_method is missing or incorrect. Please set content or source', + + if $checkcommand_file_distribution_method == 'content' { + file {"${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template("${checkcommand_template_module}/${checkcommand_template}"), + } } + elsif $checkcommand_file_distribution_method == 'source' { + file {"${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + source => $checkcommand_source_file, + } + } + else { + notify {'Missing/Incorrect File Distribution Method': + message => 'The parameter checkcommand_file_distribution_method is missing or incorrect. Please set content or source', + } + } + } + } diff --git a/manifests/object/checkresultreader.pp b/manifests/object/checkresultreader.pp index b10a179..afe4d89 100644 --- a/manifests/object/checkresultreader.pp +++ b/manifests/object/checkresultreader.pp @@ -18,7 +18,8 @@ define icinga2::object::checkresultreader ( $target_file_ensure = file, $target_file_owner = 'root', $target_file_group = 'root', - $target_file_mode = '0644' + $target_file_mode = '0644', + $refresh_icinga2_service = true ) { #Do some validation of the class' parameters: @@ -33,15 +34,33 @@ define icinga2::object::checkresultreader ( validate_string($target_file_owner) validate_string($target_file_group) validate_re($target_file_mode, '^\d{4}$') + validate_bool($refresh_icinga2_service) + #If the refresh_icinga2_service parameter is set to true... + if $refresh_icinga2_service == true { - file {"${target_dir}/${target_file_name}": - ensure => $target_file_ensure, - owner => $target_file_owner, - group => $target_file_group, - mode => $target_file_mode, - content => template('icinga2/object_checkresultreader.conf.erb'), - notify => Service['icinga2'], + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_checkresultreader.conf.erb'), + #...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file... + notify => Service['icinga2'], + } + + } + #...otherwise, use the same file resource but without a notify => parameter: + else { + + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_checkresultreader.conf.erb'), + } + } } diff --git a/manifests/object/compatlogger.pp b/manifests/object/compatlogger.pp index a0dc5ee..00edfdf 100644 --- a/manifests/object/compatlogger.pp +++ b/manifests/object/compatlogger.pp @@ -19,7 +19,8 @@ define icinga2::object::compatlogger ( $target_file_ensure = file, $target_file_owner = 'root', $target_file_group = 'root', - $target_file_mode = '0644' + $target_file_mode = '0644', + $refresh_icinga2_service = true ) { #Do some validation of the class' parameters: @@ -37,15 +38,33 @@ define icinga2::object::compatlogger ( validate_string($target_file_owner) validate_string($target_file_group) validate_re($target_file_mode, '^\d{4}$') + validate_bool($refresh_icinga2_service) + #If the refresh_icinga2_service parameter is set to true... + if $refresh_icinga2_service == true { - file {"${target_dir}/${target_file_name}": - ensure => $target_file_ensure, - owner => $target_file_owner, - group => $target_file_group, - mode => $target_file_mode, - content => template('icinga2/object_compatlogger.conf.erb'), - notify => Service['icinga2'], + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_compatlogger.conf.erb'), + #...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file... + notify => Service['icinga2'], + } + + } + #...otherwise, use the same file resource but without a notify => parameter: + else { + + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_compatlogger.conf.erb'), + } + } } diff --git a/manifests/object/dependency.pp b/manifests/object/dependency.pp index 555d77d..aa31649 100644 --- a/manifests/object/dependency.pp +++ b/manifests/object/dependency.pp @@ -25,7 +25,9 @@ define icinga2::object::dependency ( $target_file_ensure = file, $target_file_owner = 'root', $target_file_group = 'root', - $target_file_mode = '0644') { + $target_file_mode = '0644', + $refresh_icinga2_service = true + ) { # Do some validation of the class' parameters: validate_string($object_name) validate_string($display_name) @@ -43,14 +45,33 @@ define icinga2::object::dependency ( validate_string($target_file_owner) validate_string($target_file_group) validate_string($target_file_mode) + validate_bool($refresh_icinga2_service) - file { "${target_dir}/${target_file_name}": - ensure => $target_file_ensure, - owner => $target_file_owner, - group => $target_file_group, - mode => $target_file_mode, - content => template('icinga2/object_dependency.conf.erb'), - notify => Service['icinga2'], + #If the refresh_icinga2_service parameter is set to true... + if $refresh_icinga2_service == true { + + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_dependency.conf.erb'), + #...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file... + notify => Service['icinga2'], + } + + } + #...otherwise, use the same file resource but without a notify => parameter: + else { + + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_dependency.conf.erb'), + } + } } diff --git a/manifests/object/eventcommand.pp b/manifests/object/eventcommand.pp index d815d81..96dd3f0 100644 --- a/manifests/object/eventcommand.pp +++ b/manifests/object/eventcommand.pp @@ -24,7 +24,8 @@ define icinga2::object::eventcommand ( $target_file_ensure = file, $target_file_owner = 'root', $target_file_group = 'root', - $target_file_mode = '0644' + $target_file_mode = '0644', + $refresh_icinga2_service = true ) { #Do some validation of the class' parameters: @@ -43,15 +44,33 @@ define icinga2::object::eventcommand ( validate_string($target_file_owner) validate_string($target_file_group) validate_re($target_file_mode, '^\d{4}$') + validate_bool($refresh_icinga2_service) + #If the refresh_icinga2_service parameter is set to true... + if $refresh_icinga2_service == true { - file {"${target_dir}/${target_file_name}": - ensure => $target_file_ensure, - owner => $target_file_owner, - group => $target_file_group, - mode => $target_file_mode, - content => template('icinga2/object_eventcommand.conf.erb'), - notify => Service['icinga2'], + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_eventcommand.conf.erb'), + #...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file... + notify => Service['icinga2'], + } + + } + #...otherwise, use the same file resource but without a notify => parameter: + else { + + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_eventcommand.conf.erb'), + } + } } diff --git a/manifests/object/externalcommandlistener.pp b/manifests/object/externalcommandlistener.pp index 7d9f2fd..671650a 100644 --- a/manifests/object/externalcommandlistener.pp +++ b/manifests/object/externalcommandlistener.pp @@ -18,7 +18,8 @@ define icinga2::object::externalcommandlistener ( $target_file_ensure = file, $target_file_owner = 'root', $target_file_group = 'root', - $target_file_mode = '0644' + $target_file_mode = '0644', + $refresh_icinga2_service = true ) { #Do some validation of the class' parameters: @@ -33,15 +34,33 @@ define icinga2::object::externalcommandlistener ( validate_string($target_file_owner) validate_string($target_file_group) validate_re($target_file_mode, '^\d{4}$') + validate_bool($refresh_icinga2_service) + #If the refresh_icinga2_service parameter is set to true... + if $refresh_icinga2_service == true { - file {"${target_dir}/${target_file_name}": - ensure => $target_file_ensure, - owner => $target_file_owner, - group => $target_file_group, - mode => $target_file_mode, - content => template('icinga2/object_externalcommandlistener.conf.erb'), - notify => Service['icinga2'], + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_externalcommandlistener.conf.erb'), + #...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file... + notify => Service['icinga2'], + } + + } + #...otherwise, use the same file resource but without a notify => parameter: + else { + + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_externalcommandlistener.conf.erb'), + } + } } diff --git a/manifests/object/graphitewriter.pp b/manifests/object/graphitewriter.pp index cf5629b..5fd4be3 100644 --- a/manifests/object/graphitewriter.pp +++ b/manifests/object/graphitewriter.pp @@ -19,18 +19,39 @@ define icinga2::object::graphitewriter ( $target_file_ensure = file, $target_file_owner = 'root', $target_file_group = 'root', - $target_file_mode = '0644' + $target_file_mode = '0644', + $refresh_icinga2_service = true ) { #Do some validation validate_string($host) + validate_bool($refresh_icinga2_service) + + #If the refresh_icinga2_service parameter is set to true... + if $refresh_icinga2_service == true { + + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_graphitewriter.conf.erb'), + #...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file... + notify => Service['icinga2'], + } - file {"${target_dir}/${target_file_name}": - ensure => $target_file_ensure, - owner => $target_file_owner, - group => $target_file_group, - mode => $target_file_mode, - content => template('icinga2/object_graphitewriter.conf.erb'), - notify => Service['icinga2'], } + #...otherwise, use the same file resource but without a notify => parameter: + else { + + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_graphitewriter.conf.erb'), + } + + } + } diff --git a/manifests/object/host.pp b/manifests/object/host.pp index a3094e9..9937582 100644 --- a/manifests/object/host.pp +++ b/manifests/object/host.pp @@ -42,7 +42,8 @@ define icinga2::object::host ( $target_file_ensure = file, $target_file_owner = 'root', $target_file_group = 'root', - $target_file_mode = '0644' + $target_file_mode = '0644', + $refresh_icinga2_service = true ) { #Do some validation of the class' parameters: @@ -57,14 +58,33 @@ define icinga2::object::host ( validate_string($target_file_owner) validate_string($target_file_group) validate_string($target_file_mode) + validate_bool($refresh_icinga2_service) - file {"${target_dir}/${target_file_name}": - ensure => $target_file_ensure, - owner => $target_file_owner, - group => $target_file_group, - mode => $target_file_mode, - content => template('icinga2/object_host.conf.erb'), - notify => Service['icinga2'], + #If the refresh_icinga2_service parameter is set to true... + if $refresh_icinga2_service == true { + + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_host.conf.erb'), + #...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file... + notify => Service['icinga2'], + } + + } + #...otherwise, use the same file resource but without a notify => parameter: + else { + + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_host.conf.erb'), + } + } } diff --git a/manifests/object/hostgroup.pp b/manifests/object/hostgroup.pp index 2ded337..dde685b 100644 --- a/manifests/object/hostgroup.pp +++ b/manifests/object/hostgroup.pp @@ -21,7 +21,8 @@ define icinga2::object::hostgroup ( $target_file_group = 'root', $target_file_mode = '0644', $assign_where = undef, - $ignore_where = undef + $ignore_where = undef, + $refresh_icinga2_service = true ) { #Do some validation of the class' parameters: @@ -34,14 +35,33 @@ define icinga2::object::hostgroup ( validate_string($target_file_owner) validate_string($target_file_group) validate_string($target_file_mode) + validate_bool($refresh_icinga2_service) - file {"${target_dir}/${target_file_name}": - ensure => $target_file_ensure, - owner => $target_file_owner, - group => $target_file_group, - mode => $target_file_mode, - content => template('icinga2/object_hostgroup.conf.erb'), - notify => Service['icinga2'], + #If the refresh_icinga2_service parameter is set to true... + if $refresh_icinga2_service == true { + + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_hostgroup.conf.erb'), + #...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file... + notify => Service['icinga2'], + } + + } + #...otherwise, use the same file resource but without a notify => parameter: + else { + + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_hostgroup.conf.erb'), + } + } } diff --git a/manifests/object/idomysqlconnection.pp b/manifests/object/idomysqlconnection.pp index d411e07..7e7eb42 100644 --- a/manifests/object/idomysqlconnection.pp +++ b/manifests/object/idomysqlconnection.pp @@ -42,7 +42,8 @@ define icinga2::object::idomysqlconnection ( $target_file_name = "${name}.conf", $target_file_owner = 'root', $target_file_group = 'root', - $target_file_mode = '0644' + $target_file_mode = '0644', + $refresh_icinga2_service = true ) { #Do some validation of the class' parameters: @@ -61,14 +62,33 @@ define icinga2::object::idomysqlconnection ( validate_string($target_file_owner) validate_string($target_file_group) validate_string($target_file_mode) + validate_bool($refresh_icinga2_service) - file {"${target_dir}/${target_file_name}": - ensure => $target_file_ensure, - owner => $target_file_owner, - group => $target_file_group, - mode => $target_file_mode, - content => template('icinga2/object_idomysqlconnection.conf.erb'), - notify => Service['icinga2'], + #If the refresh_icinga2_service parameter is set to true... + if $refresh_icinga2_service == true { + + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_idomysqlconnection.conf.erb'), + #...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file... + notify => Service['icinga2'], + } + + } + #...otherwise, use the same file resource but without a notify => parameter: + else { + + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_idomysqlconnection.conf.erb'), + } + } } diff --git a/manifests/object/idopgsqlconnection.pp b/manifests/object/idopgsqlconnection.pp index 2a269a3..f281b99 100644 --- a/manifests/object/idopgsqlconnection.pp +++ b/manifests/object/idopgsqlconnection.pp @@ -42,7 +42,8 @@ define icinga2::object::idopgsqlconnection ( $target_file_ensure = file, $target_file_owner = 'root', $target_file_group = 'root', - $target_file_mode = '0644' + $target_file_mode = '0644', + $refresh_icinga2_service = true ) { #Do some validation of the class' parameters: @@ -61,14 +62,33 @@ define icinga2::object::idopgsqlconnection ( validate_string($target_file_owner) validate_string($target_file_group) validate_string($target_file_mode) + validate_bool($refresh_icinga2_service) - file {"${target_dir}/${target_file_name}": - ensure => $target_file_ensure, - owner => $target_file_owner, - group => $target_file_group, - mode => $target_file_mode, - content => template('icinga2/object_idopgsqlconnection.conf.erb'), - notify => Service['icinga2'], + #If the refresh_icinga2_service parameter is set to true... + if $refresh_icinga2_service == true { + + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_idopgsqlconnection.conf.erb'), + #...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file... + notify => Service['icinga2'], + } + + } + #...otherwise, use the same file resource but without a notify => parameter: + else { + + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_idopgsqlconnection.conf.erb'), + } + } } diff --git a/manifests/object/livestatuslistener.pp b/manifests/object/livestatuslistener.pp index 8ad7980..19290fc 100644 --- a/manifests/object/livestatuslistener.pp +++ b/manifests/object/livestatuslistener.pp @@ -10,7 +10,7 @@ # define icinga2::object::livestatuslistener ( - $object_livestatuslistenername = $name, + $object_livestatuslistenername = $name, $socket_type = undef, $bind_host = undef, $bind_port = undef, @@ -21,7 +21,8 @@ define icinga2::object::livestatuslistener ( $target_file_ensure = file, $target_file_owner = 'root', $target_file_group = 'root', - $target_file_mode = '0644' + $target_file_mode = '0644', + $refresh_icinga2_service = true ) { #Do some validation of the class' parameters: @@ -48,15 +49,33 @@ define icinga2::object::livestatuslistener ( validate_string($target_file_owner) validate_string($target_file_group) validate_re($target_file_mode, '^\d{4}$') + validate_bool($refresh_icinga2_service) + #If the refresh_icinga2_service parameter is set to true... + if $refresh_icinga2_service == true { - file {"${target_dir}/${target_file_name}": - ensure => $target_file_ensure, - owner => $target_file_owner, - group => $target_file_group, - mode => $target_file_mode, - content => template('icinga2/object_livestatuslistener.conf.erb'), - notify => Service['icinga2'], + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_livestatuslistener.conf.erb'), + #...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file... + notify => Service['icinga2'], + } + + } + #...otherwise, use the same file resource but without a notify => parameter: + else { + + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_livestatuslistener.conf.erb'), + } + } } diff --git a/manifests/object/notification.pp b/manifests/object/notification.pp index bc0e678..e8d5b4e 100644 --- a/manifests/object/notification.pp +++ b/manifests/object/notification.pp @@ -27,7 +27,8 @@ define icinga2::object::notification ( $target_file_ensure = file, $target_file_owner = 'root', $target_file_group = 'root', - $target_file_mode = '0644' + $target_file_mode = '0644', + $refresh_icinga2_service = true ) { #Do some validation of the class' parameters: @@ -66,15 +67,33 @@ define icinga2::object::notification ( validate_string($target_file_owner) validate_string($target_file_group) validate_re($target_file_mode, '^\d{4}$') + validate_bool($refresh_icinga2_service) + #If the refresh_icinga2_service parameter is set to true... + if $refresh_icinga2_service == true { - file {"${target_dir}/${target_file_name}": - ensure => $target_file_ensure, - owner => $target_file_owner, - group => $target_file_group, - mode => $target_file_mode, - content => template('icinga2/object_notification.conf.erb'), - notify => Service['icinga2'], + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_notification.conf.erb'), + #...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file... + notify => Service['icinga2'], + } + + } + #...otherwise, use the same file resource but without a notify => parameter: + else { + + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_notification.conf.erb'), + } + } } diff --git a/manifests/object/notificationcommand.pp b/manifests/object/notificationcommand.pp index 57bc252..d909c47 100644 --- a/manifests/object/notificationcommand.pp +++ b/manifests/object/notificationcommand.pp @@ -24,7 +24,8 @@ define icinga2::object::notificationcommand ( $target_file_ensure = file, $target_file_owner = 'root', $target_file_group = 'root', - $target_file_mode = '0644' + $target_file_mode = '0644', + $refresh_icinga2_service = true ) { #Do some validation of the class' parameters: @@ -43,15 +44,33 @@ define icinga2::object::notificationcommand ( validate_string($target_file_owner) validate_string($target_file_group) validate_re($target_file_mode, '^\d{4}$') + validate_bool($refresh_icinga2_service) + #If the refresh_icinga2_service parameter is set to true... + if $refresh_icinga2_service == true { - file {"${target_dir}/${target_file_name}": - ensure => $target_file_ensure, - owner => $target_file_owner, - group => $target_file_group, - mode => $target_file_mode, - content => template('icinga2/object_notificationcommand.conf.erb'), - notify => Service['icinga2'], + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_notificationcommand.conf.erb'), + #...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file... + notify => Service['icinga2'], + } + + } + #...otherwise, use the same file resource but without a notify => parameter: + else { + + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_notificationcommand.conf.erb'), + } + } } diff --git a/manifests/object/perfdatawriter.pp b/manifests/object/perfdatawriter.pp index 4a47d17..946a8a2 100644 --- a/manifests/object/perfdatawriter.pp +++ b/manifests/object/perfdatawriter.pp @@ -24,7 +24,8 @@ define icinga2::object::perfdatawriter ( $target_file_ensure = file, $target_file_owner = 'root', $target_file_group = 'root', - $target_file_mode = '0644' + $target_file_mode = '0644', + $refresh_icinga2_service = true ) { #Do some validation of the class' parameters: @@ -57,15 +58,33 @@ define icinga2::object::perfdatawriter ( validate_string($target_file_owner) validate_string($target_file_group) validate_re($target_file_mode, '^\d{4}$') + validate_bool($refresh_icinga2_service) + #If the refresh_icinga2_service parameter is set to true... + if $refresh_icinga2_service == true { - file {"${target_dir}/${target_file_name}": - ensure => $target_file_ensure, - owner => $target_file_owner, - group => $target_file_group, - mode => $target_file_mode, - content => template('icinga2/object_perfdatawriter.conf.erb'), - notify => Service['icinga2'], + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_perfdatawriter.conf.erb'), + #...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file... + notify => Service['icinga2'], + } + + } + #...otherwise, use the same file resource but without a notify => parameter: + else { + + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_perfdatawriter.conf.erb'), + } + } } diff --git a/manifests/object/scheduleddowntime.pp b/manifests/object/scheduleddowntime.pp index 9d0a87b..1b3c7fb 100644 --- a/manifests/object/scheduleddowntime.pp +++ b/manifests/object/scheduleddowntime.pp @@ -23,7 +23,8 @@ define icinga2::object::scheduleddowntime ( $target_file_ensure = file, $target_file_owner = 'root', $target_file_group = 'root', - $target_file_mode = '0644' + $target_file_mode = '0644', + $refresh_icinga2_service = true ) { #Do some validation of the define's parameters: @@ -42,14 +43,33 @@ define icinga2::object::scheduleddowntime ( validate_string($target_file_owner) validate_string($target_file_group) validate_string($target_file_mode) + validate_bool($refresh_icinga2_service) - file {"${target_dir}/${target_file_name}": - ensure => $target_file_ensure, - owner => $target_file_owner, - group => $target_file_group, - mode => $target_file_mode, - content => template('icinga2/object_scheduleddowntime.conf.erb'), - notify => Service['icinga2'], + #If the refresh_icinga2_service parameter is set to true... + if $refresh_icinga2_service == true { + + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_scheduleddowntime.conf.erb'), + #...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file... + notify => Service['icinga2'], + } + + } + #...otherwise, use the same file resource but without a notify => parameter: + else { + + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_scheduleddowntime.conf.erb'), + } + } } diff --git a/manifests/object/service.pp b/manifests/object/service.pp index 9cf7a82..e6af2da 100644 --- a/manifests/object/service.pp +++ b/manifests/object/service.pp @@ -41,7 +41,8 @@ define icinga2::object::service ( $target_file_ensure = file, $target_file_owner = 'root', $target_file_group = 'root', - $target_file_mode = '0644' + $target_file_mode = '0644', + $refresh_icinga2_service = true ) { #Do some validation of the class' parameters: @@ -56,14 +57,33 @@ define icinga2::object::service ( validate_string($target_file_owner) validate_string($target_file_group) validate_string($target_file_mode) + validate_bool($refresh_icinga2_service) - file {"${target_dir}/${target_file_name}": - ensure => $target_file_ensure, - owner => $target_file_owner, - group => $target_file_group, - mode => $target_file_mode, - content => template('icinga2/object_service.conf.erb'), - notify => Service['icinga2'], + #If the refresh_icinga2_service parameter is set to true... + if $refresh_icinga2_service == true { + + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_service.conf.erb'), + #...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file... + notify => Service['icinga2'], + } + + } + #...otherwise, use the same file resource but without a notify => parameter: + else { + + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_service.conf.erb'), + } + } } diff --git a/manifests/object/servicegroup.pp b/manifests/object/servicegroup.pp index 2b9b260..2650fed 100644 --- a/manifests/object/servicegroup.pp +++ b/manifests/object/servicegroup.pp @@ -21,7 +21,8 @@ define icinga2::object::servicegroup ( $target_file_group = 'root', $target_file_mode = '0644', $assign_where = undef, - $ignore_where = undef + $ignore_where = undef, + $refresh_icinga2_service = true ) { #Do some validation of the class' parameters: @@ -34,14 +35,33 @@ define icinga2::object::servicegroup ( validate_string($target_file_owner) validate_string($target_file_group) validate_string($target_file_mode) + validate_bool($refresh_icinga2_service) - file {"${target_dir}/${target_file_name}": - ensure => $target_file_ensure, - owner => $target_file_owner, - group => $target_file_group, - mode => $target_file_mode, - content => template('icinga2/object_servicegroup.conf.erb'), - notify => Service['icinga2'], + #If the refresh_icinga2_service parameter is set to true... + if $refresh_icinga2_service == true { + + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_servicegroup.conf.erb'), + #...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file... + notify => Service['icinga2'], + } + + } + #...otherwise, use the same file resource but without a notify => parameter: + else { + + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_servicegroup.conf.erb'), + } + } } diff --git a/manifests/object/statusdatawriter.pp b/manifests/object/statusdatawriter.pp index 563e11c..34fd8a2 100644 --- a/manifests/object/statusdatawriter.pp +++ b/manifests/object/statusdatawriter.pp @@ -19,7 +19,8 @@ define icinga2::object::statusdatawriter ( $target_file_ensure = file, $target_file_owner = 'root', $target_file_group = 'root', - $target_file_mode = '0644' + $target_file_mode = '0644', + $refresh_icinga2_service = true ) { #Do some validation of the class' parameters: @@ -40,15 +41,33 @@ define icinga2::object::statusdatawriter ( validate_string($target_file_owner) validate_string($target_file_group) validate_re($target_file_mode, '^\d{4}$') + validate_bool($refresh_icinga2_service) + #If the refresh_icinga2_service parameter is set to true... + if $refresh_icinga2_service == true { - file {"${target_dir}/${target_file_name}": - ensure => $target_file_ensure, - owner => $target_file_owner, - group => $target_file_group, - mode => $target_file_mode, - content => template('icinga2/object_statusdatawriter.conf.erb'), - notify => Service['icinga2'], + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_statusdatawriter.conf.erb'), + #...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file... + notify => Service['icinga2'], + } + + } + #...otherwise, use the same file resource but without a notify => parameter: + else { + + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_statusdatawriter.conf.erb'), + } + } } diff --git a/manifests/object/sysloglogger.pp b/manifests/object/sysloglogger.pp index 7ad8f02..fd72091 100644 --- a/manifests/object/sysloglogger.pp +++ b/manifests/object/sysloglogger.pp @@ -17,7 +17,8 @@ define icinga2::object::sysloglogger ( $target_file_ensure = file, $target_file_owner = 'root', $target_file_group = 'root', - $target_file_mode = '0644' + $target_file_mode = '0644', + $refresh_icinga2_service = true ) { #Do some validation of the class' parameters: @@ -28,14 +29,33 @@ define icinga2::object::sysloglogger ( validate_string($target_file_owner) validate_string($target_file_group) validate_string($target_file_mode) + validate_bool($refresh_icinga2_service) - file {"${target_dir}/${target_file_name}": - ensure => $target_file_ensure, - owner => $target_file_owner, - group => $target_file_group, - mode => $target_file_mode, - content => template('icinga2/object_sysloglogger.conf.erb'), - notify => Service['icinga2'], + #If the refresh_icinga2_service parameter is set to true... + if $refresh_icinga2_service == true { + + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_sysloglogger.conf.erb'), + #...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file... + notify => Service['icinga2'], + } + + } + #...otherwise, use the same file resource but without a notify => parameter: + else { + + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_sysloglogger.conf.erb'), + } + } } diff --git a/manifests/object/timeperiod.pp b/manifests/object/timeperiod.pp index ccf8d21..7643384 100644 --- a/manifests/object/timeperiod.pp +++ b/manifests/object/timeperiod.pp @@ -15,12 +15,13 @@ define icinga2::object::timeperiod ( $timeperiod_display_name = undef, $methods = undef, $ranges = {}, - $timeperiod_target_dir = '/etc/icinga2/objects/timeperiods', - $timeperiod_target_file_name = "${name}.conf", + $target_dir = '/etc/icinga2/objects/timeperiods', + $target_file_name = "${name}.conf", $target_file_ensure = file, $target_file_owner = 'root', $target_file_group = 'root', $target_file_mode = '0644', + $refresh_icinga2_service = true ) { # Do some validation of the class' parameters: @@ -36,13 +37,33 @@ define icinga2::object::timeperiod ( validate_string($target_file_owner) validate_string($target_file_group) validate_re($target_file_mode, '^\d{4}$') + validate_bool($refresh_icinga2_service) + + #If the refresh_icinga2_service parameter is set to true... + if $refresh_icinga2_service == true { + + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_timeperiod.conf.erb'), + #...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file... + notify => Service['icinga2'], + } - file {"${timeperiod_target_dir}/${timeperiod_target_file_name}": - ensure => $target_file_ensure, - owner => $target_file_owner, - group => $target_file_group, - mode => $target_file_mode, - content => template('icinga2/object_timeperiod.conf.erb'), - notify => Service['icinga2'], } + #...otherwise, use the same file resource but without a notify => parameter: + else { + + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_timeperiod.conf.erb'), + } + + } + } diff --git a/manifests/object/user.pp b/manifests/object/user.pp index bb6f0ac..21ea6d7 100644 --- a/manifests/object/user.pp +++ b/manifests/object/user.pp @@ -25,7 +25,8 @@ define icinga2::object::user ( $target_file_ensure = file, $target_file_owner = 'root', $target_file_group = 'root', - $target_file_mode = '0644' + $target_file_mode = '0644', + $refresh_icinga2_service = true ) { #Do some validation of the class' parameters: @@ -41,14 +42,33 @@ define icinga2::object::user ( validate_string($target_file_owner) validate_string($target_file_group) validate_string($target_file_mode) + validate_bool($refresh_icinga2_service) - file {"${target_dir}/${target_file_name}": - ensure => $target_file_ensure, - owner => $target_file_owner, - group => $target_file_group, - mode => $target_file_mode, - content => template('icinga2/object_user.conf.erb'), - notify => Service['icinga2'], + #If the refresh_icinga2_service parameter is set to true... + if $refresh_icinga2_service == true { + + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_user.conf.erb'), + #...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file... + notify => Service['icinga2'], + } + + } + #...otherwise, use the same file resource but without a notify => parameter: + else { + + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_user.conf.erb'), + } + } } diff --git a/manifests/object/usergroup.pp b/manifests/object/usergroup.pp index 9137450..7c96545 100644 --- a/manifests/object/usergroup.pp +++ b/manifests/object/usergroup.pp @@ -21,7 +21,8 @@ define icinga2::object::usergroup ( $target_file_group = 'root', $target_file_mode = '0644', $assign_where = undef, - $ignore_where = undef + $ignore_where = undef, + $refresh_icinga2_service = true ) { #Do some validation of the class' parameters: @@ -33,14 +34,33 @@ define icinga2::object::usergroup ( validate_string($target_file_owner) validate_string($target_file_group) validate_string($target_file_mode) + validate_bool($refresh_icinga2_service) - file {"${target_dir}/${target_file_name}": - ensure => $target_file_ensure, - owner => $target_file_owner, - group => $target_file_group, - mode => $target_file_mode, - content => template('icinga2/object_usergroup.conf.erb'), - notify => Service['icinga2'], + #If the refresh_icinga2_service parameter is set to true... + if $refresh_icinga2_service == true { + + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_usergroup.conf.erb'), + #...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file... + notify => Service['icinga2'], + } + + } + #...otherwise, use the same file resource but without a notify => parameter: + else { + + file { "${target_dir}/${target_file_name}": + ensure => $target_file_ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_usergroup.conf.erb'), + } + } }