From cb88b96207634581f1902b04e05e1d79f44adcf2 Mon Sep 17 00:00:00 2001 From: "ricardo@cropalato.com.br" Date: Thu, 20 Nov 2014 19:09:25 -0500 Subject: [PATCH 01/17] Adding CheckResultReader object. #7226. --- README.md | 15 +++++++ manifests/object/checkresultreader.pp | 47 +++++++++++++++++++++ templates/object_checkresultreader.conf.erb | 20 +++++++++ 3 files changed, 82 insertions(+) create mode 100644 manifests/object/checkresultreader.pp create mode 100644 templates/object_checkresultreader.conf.erb diff --git a/README.md b/README.md index 9142188..e5f07d9 100644 --- a/README.md +++ b/README.md @@ -365,6 +365,7 @@ Object types: * [icinga2::object::applynotificationtohost](#icinga2objectapplynotificationtohost) * [icinga2::object::applynotificationtoservice](#icinga2objectapplynotificationtoservice) * [icinga2::object::checkcommand](#icinga2objectcheckcommand) +* [icinga2::object::checkresultreader](#icinga2objectcheckresultreader) * [icinga2::object::eventcommand](#icinga2objecteventcommand) * [icinga2::object::externalcommandlistener](#icinga2objectexternalcommandlistener) * [icinga2::object::host](#icinga2objecthost) @@ -506,6 +507,20 @@ Available parameters are: * `target_file_group` * `target_file_mode` +####[`icinga2::object::checkresultreader`](id:object_checkresultreader) + +The `checkresultreader` defined type can create `checkresultreader` objects. + +Example: + +
+icinga2::object::checkresultreader {'reader':
+  spool_dir => '/data/check-results'
+}
+
+ +See [CheckResultReader](http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2#objecttype-checkresultreader) on [docs.icinga.org](http://docs.icinga.org/icinga2/latest/doc/module/icinga2/toc) for a full list of parameters. + ####`icinga2::object::eventcommand` The `eventcommand` defined type can create `eventcommand` objects. diff --git a/manifests/object/checkresultreader.pp b/manifests/object/checkresultreader.pp new file mode 100644 index 0000000..b10a179 --- /dev/null +++ b/manifests/object/checkresultreader.pp @@ -0,0 +1,47 @@ +# == Defined type: icinga2::object::checkresultreader +# +# This is a defined type for Icinga 2 apply objects that create Check Result Reader +# See the following Icinga 2 doc page for more info: +# http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2#objecttype-checkresultreader +# +# === Parameters +# +# See the inline comments. +# + +define icinga2::object::checkresultreader ( + $ensure = 'file', + $object_checkresultreadername = $name, + $spool_dir = undef, + $target_dir = '/etc/icinga2/objects/checkresultreaders', + $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: + if $object_checkresultreadername { + validate_string($object_checkresultreadername) + } + if $spool_dir { + validate_string($spool_dir) + } + validate_string($target_dir) + validate_string($target_file_name) + validate_string($target_file_owner) + validate_string($target_file_group) + validate_re($target_file_mode, '^\d{4}$') + + + 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'], + } + +} diff --git a/templates/object_checkresultreader.conf.erb b/templates/object_checkresultreader.conf.erb new file mode 100644 index 0000000..a2fc393 --- /dev/null +++ b/templates/object_checkresultreader.conf.erb @@ -0,0 +1,20 @@ +/** +* WARNING: This CheckResultReader definition is automatically generated by Puppet. +* ANY MANUAL CHANGES TO IT WILL GET OVERWRITTEN! +*/ + +/** +* A CheckResultReader definition. You can create your own configuration files +* in the conf.d directory (e.g. one per commnand). By default all *.conf +* files in this directory are included. +* +*/ + +library "compat" + +object CheckResultReader "<%= @object_checkresultreadername %>" { + <%#- If any of the @ parameters are undefined, don't print anything for them: -%> + <%- if @spool_dir -%> + spool_dir = "<%= @spool_dir %>" + <%- end -%> +} From b15b7fbaaaf9442367bd375e02b0e058a1e70ba1 Mon Sep 17 00:00:00 2001 From: "ricardo@cropalato.com.br" Date: Thu, 20 Nov 2014 18:43:21 -0500 Subject: [PATCH 02/17] Adding CompatLogger object. #7225. Signed-off-by: Nick Chappell Merged from: https://github.com/Icinga/puppet-icinga2/pull/54 refs#7225: https://dev.icinga.org/issues/7225 --- README.md | 15 ++++++++ manifests/object/compatlogger.pp | 51 ++++++++++++++++++++++++++ templates/object_compatlogger.conf.erb | 24 ++++++++++++ 3 files changed, 90 insertions(+) create mode 100644 manifests/object/compatlogger.pp create mode 100644 templates/object_compatlogger.conf.erb diff --git a/README.md b/README.md index 9142188..9137a60 100644 --- a/README.md +++ b/README.md @@ -365,6 +365,7 @@ Object types: * [icinga2::object::applynotificationtohost](#icinga2objectapplynotificationtohost) * [icinga2::object::applynotificationtoservice](#icinga2objectapplynotificationtoservice) * [icinga2::object::checkcommand](#icinga2objectcheckcommand) +* [icinga2::object::compatlogger](#icinga2objectcompatlogger) * [icinga2::object::eventcommand](#icinga2objecteventcommand) * [icinga2::object::externalcommandlistener](#icinga2objectexternalcommandlistener) * [icinga2::object::host](#icinga2objecthost) @@ -506,6 +507,20 @@ Available parameters are: * `target_file_group` * `target_file_mode` +####`icinga2::object::compatlogger` + +The `compatlogger` defined type can create `compatlogger` objects. + +
+icinga2::object::compatlogger { 'daily-log':
+  log_dir         => '/var/log/icinga2/compat',
+  rotation_method => 'DAILY'
+}
+
+ +Both patameters as optionals. The parameter `rotation_method` can one of `HOURLY`, `DAILY`, `WEEKLY` or `MONTHY`. +See [CompatLogger](http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2#objecttype-compatlogger) on [docs.icinga.org](http://docs.icinga.org/icinga2/latest/doc/module/icinga2/toc) for a full list of parameters. + ####`icinga2::object::eventcommand` The `eventcommand` defined type can create `eventcommand` objects. diff --git a/manifests/object/compatlogger.pp b/manifests/object/compatlogger.pp new file mode 100644 index 0000000..a0dc5ee --- /dev/null +++ b/manifests/object/compatlogger.pp @@ -0,0 +1,51 @@ +# == Defined type: icinga2::object::compatlogger +# +# This is a defined type for Icinga 2 apply objects that create Compat Logger +# See the following Icinga 2 doc page for more info: +# http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2#objecttype-compatlogger +# +# === Parameters +# +# See the inline comments. +# + +define icinga2::object::compatlogger ( + $ensure = 'file', + $object_compatloggername = $name, + $log_dir = undef, + $rotation_method = undef, + $target_dir = '/etc/icinga2/objects/compatloggers', + $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: + if $object_compatloggername { + validate_string($object_compatloggername) + } + if $log_dir { + validate_string($log_dir) + } + if $rotation_method { + validate_string($rotation_method) + } + validate_string($target_dir) + validate_string($target_file_name) + validate_string($target_file_owner) + validate_string($target_file_group) + validate_re($target_file_mode, '^\d{4}$') + + + 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'], + } + +} diff --git a/templates/object_compatlogger.conf.erb b/templates/object_compatlogger.conf.erb new file mode 100644 index 0000000..17004f8 --- /dev/null +++ b/templates/object_compatlogger.conf.erb @@ -0,0 +1,24 @@ +/** +* WARNING: This CompatLogger definition is automatically generated by Puppet. +* ANY MANUAL CHANGES TO IT WILL GET OVERWRITTEN! +*/ + +/** +* A CompatLogger definition. You can create your own configuration files +* in the conf.d directory (e.g. one per commnand). By default all *.conf +* files in this directory are included. +* +*/ + +library "compat" + +object CompatLogger "<%= @object_compatloggername %>" { + <%#- If any of the @ parameters are undefined, don't print anything for them: -%> + <%- if @log_dir -%> + + log_dir = "<%= @log_dir %>" + <%- end -%> + <%- if @rotation_method -%> + rotation_method = "<%= @rotation_method %>" + <%- end -%> +} From 14b58cd739ff444d56431961eedbcdc98027c1cd Mon Sep 17 00:00:00 2001 From: Nick Chappell Date: Fri, 21 Nov 2014 21:03:16 -0800 Subject: [PATCH 03/17] CHANGELOG update. --- CHANGELOG.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 95c85b6..a3df323 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ #Changelog - - - +###v0.6.1 (unreleased) + +* Feature: [PR-54](https://github.com/Icinga/puppet-icinga2/pull/54) and [dev.icinga.org issue #7225](https://dev.icinga.org/issues/7225): Added a CompatLogger object defined type. + + ###v0.6.0 (November 19th, 2014) * Added a defined type for `ServiceGroup` objects @@ -10,7 +15,7 @@ * Feature [#7264](https://dev.icinga.org/issues/7264): Added Debian 7 support * Feature: Added the ability to use the Debmon repository on Debian 7 systems: [PR-17](https://github.com/Icinga/puppet-icinga2/pull/17) * Feature: Added the ability to make NRPE accept command arguments; turned off by default for obvious security reasons: [PR-22](https://github.com/Icinga/puppet-icinga2/pull/22) -* Feature: Added the ability to enable/disable Icinga 2 components via parameters: [PR-23](https://github.com/Icinga/puppet-icinga2/pull/23) +* Feature: Added the ability to enable/disable Icinga 2 components via parameters: [PR-23](https://github.com/Icinga/puppet-icinga2/pull/23) * Feature: Added a `GraphiteWriter` object defined type: [PR-24](https://github.com/Icinga/puppet-icinga2/pull/24) * Feature: Added the ability to upload or create custom check plugins on an Icinga 2 server (as opposed to just for NRPE clients): [PR-27](https://github.com/Icinga/puppet-icinga2/pull/27) * Bug [#7308](https://dev.icinga.org/issues/7308): Allow multiple `assign_where` and `ignore_where` conditions From c4152dd507ff437dcd952b1d9e5907ab249b0a66 Mon Sep 17 00:00:00 2001 From: Nick Chappell Date: Fri, 21 Nov 2014 21:17:23 -0800 Subject: [PATCH 04/17] CHANGELOG update. --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a3df323..ea0fbd3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ ###v0.6.1 (unreleased) * Feature: [PR-54](https://github.com/Icinga/puppet-icinga2/pull/54) and [dev.icinga.org issue #7225](https://dev.icinga.org/issues/7225): Added a CompatLogger object defined type. - +* Feature: [PR-55](https://github.com/Icinga/puppet-icinga2/pull/55) and [dev.icinga.org issue #7226](https://dev.icinga.org/issues/7226): Added a CheckResultReader object defined type. ###v0.6.0 (November 19th, 2014) From 1f92973f8c6473bbca24aaf4fe3d537870776faf Mon Sep 17 00:00:00 2001 From: Nick Chappell Date: Fri, 21 Nov 2014 21:20:48 -0800 Subject: [PATCH 05/17] Fix the in-manifest links to the docs pages for some of the object types. --- manifests/object/apply_service_to_host.pp | 3 ++- manifests/object/timeperiod.pp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/manifests/object/apply_service_to_host.pp b/manifests/object/apply_service_to_host.pp index 12358de..81d811a 100644 --- a/manifests/object/apply_service_to_host.pp +++ b/manifests/object/apply_service_to_host.pp @@ -2,7 +2,8 @@ # # This is a defined type for Icinga 2 apply objects that apply services to hosts. # See the following Icinga 2 doc page for more info: -# http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2#objecttype-service +# http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2#objecttype-host +# http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2#apply # # === Parameters # diff --git a/manifests/object/timeperiod.pp b/manifests/object/timeperiod.pp index 1e8d368..ccf8d21 100644 --- a/manifests/object/timeperiod.pp +++ b/manifests/object/timeperiod.pp @@ -2,7 +2,7 @@ # # This is a defined type for Icinga 2 host objects. # See the following Icinga 2 doc page for more info: -# http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/monitoring-basics#timeperiods +# http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2#objecttype-timeperiod # # === Parameters # From 13e1100d0c3952d2f3a858ce0fd311145efe1a0c Mon Sep 17 00:00:00 2001 From: Nick Chappell Date: Fri, 21 Nov 2014 21:24:05 -0800 Subject: [PATCH 06/17] Fix the target_file_dir parameters so they're consistent with the other object defined types. --- manifests/object/host.pp | 2 +- manifests/object/hostgroup.pp | 2 +- manifests/object/servicegroup.pp | 2 +- manifests/object/sysloglogger.pp | 2 +- manifests/object/user.pp | 2 +- manifests/object/usergroup.pp | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/manifests/object/host.pp b/manifests/object/host.pp index 123e360..a3094e9 100644 --- a/manifests/object/host.pp +++ b/manifests/object/host.pp @@ -37,7 +37,7 @@ define icinga2::object::host ( $action_url = undef, $icon_image = undef, $icon_image_alt = undef, - $target_dir = '/etc/icinga2/conf.d', + $target_dir = '/etc/icinga2/objects', $target_file_name = "${fqdn}.conf", $target_file_ensure = file, $target_file_owner = 'root', diff --git a/manifests/object/hostgroup.pp b/manifests/object/hostgroup.pp index 95937b4..2ded337 100644 --- a/manifests/object/hostgroup.pp +++ b/manifests/object/hostgroup.pp @@ -14,7 +14,7 @@ define icinga2::object::hostgroup ( $display_name = $name, $template_to_import = undef, $groups = [], - $target_dir = '/etc/icinga2/conf.d', + $target_dir = '/etc/icinga2/objects', $target_file_name = "${name}.conf", $target_file_ensure = file, $target_file_owner = 'root', diff --git a/manifests/object/servicegroup.pp b/manifests/object/servicegroup.pp index 67c8538..2b9b260 100644 --- a/manifests/object/servicegroup.pp +++ b/manifests/object/servicegroup.pp @@ -14,7 +14,7 @@ define icinga2::object::servicegroup ( $display_name = $name, $template_to_import = undef, $groups = [], - $target_dir = '/etc/icinga2/conf.d', + $target_dir = '/etc/icinga2/objects', $target_file_name = "${name}.conf", $target_file_ensure = file, $target_file_owner = 'root', diff --git a/manifests/object/sysloglogger.pp b/manifests/object/sysloglogger.pp index c33c682..7ad8f02 100644 --- a/manifests/object/sysloglogger.pp +++ b/manifests/object/sysloglogger.pp @@ -12,7 +12,7 @@ define icinga2::object::sysloglogger ( $object_name = $name, $severity = 'warning', - $target_dir = '/etc/icinga2/conf.d', + $target_dir = '/etc/icinga2/objects', $target_file_name = "${name}.conf", $target_file_ensure = file, $target_file_owner = 'root', diff --git a/manifests/object/user.pp b/manifests/object/user.pp index 327ea0b..bb6f0ac 100644 --- a/manifests/object/user.pp +++ b/manifests/object/user.pp @@ -20,7 +20,7 @@ define icinga2::object::user ( $period = undef, $types = [], $states = [], - $target_dir = '/etc/icinga2/conf.d', + $target_dir = '/etc/icinga2/objects', $target_file_name = "${name}.conf", $target_file_ensure = file, $target_file_owner = 'root', diff --git a/manifests/object/usergroup.pp b/manifests/object/usergroup.pp index 3c58096..9137450 100644 --- a/manifests/object/usergroup.pp +++ b/manifests/object/usergroup.pp @@ -14,7 +14,7 @@ define icinga2::object::usergroup ( $display_name = $name, $template_to_import = undef, $groups = [], - $target_dir = '/etc/icinga2/conf.d', + $target_dir = '/etc/icinga2/objects', $target_file_name = "${name}.conf", $target_file_ensure = file, $target_file_owner = 'root', From 17d230eb2b3b34be8db499a4f93e92651d77538a Mon Sep 17 00:00:00 2001 From: Nick Chappell Date: Fri, 21 Nov 2014 21:49:26 -0800 Subject: [PATCH 07/17] Added a parameter that controls whether non-Puppet managed object files get purged. --- manifests/params.pp | 3 +++ manifests/server.pp | 1 + manifests/server/config.pp | 15 +++++++++++++++ 3 files changed, 19 insertions(+) diff --git a/manifests/params.pp b/manifests/params.pp index f0382bb..0871254 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -235,6 +235,9 @@ class icinga2::params { #Fail if we're on any other OS: default: { fail("${::operatingsystem} is not supported!") } } + + #Whether to purge object files or directories in /etc/icinga2/objects that aren't managed by Puppet + $purge_unmanaged_object_files = false ################## # Icinga 2 server service settings diff --git a/manifests/server.pp b/manifests/server.pp index e93a15f..32d9932 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -26,6 +26,7 @@ class icinga2::server ( $install_mail_utils_package = $icinga2::params::install_mail_utils_package, $server_enabled_features = $icinga2::params::server_enabled_features, $server_disabled_features = $icinga2::params::server_disabled_features, + $purge_unmanaged_object_files = $icinga2::params::purge_unmanaged_object_files ) inherits icinga2::params { #Do some validation of parameters so we know we have the right data types: diff --git a/manifests/server/config.pp b/manifests/server/config.pp index 989d280..ee46770 100644 --- a/manifests/server/config.pp +++ b/manifests/server/config.pp @@ -15,6 +15,18 @@ class icinga2::server::config inherits icinga2::server { include icinga2::params + if $purge_unmanaged_object_files == true { + $recurse_objects = true + $purge_objects = true + $force_purge = true + } + else { + $recurse_objects = false + $purge_objects = false + $force_purge = true + } + + #Directory resource for /etc/icinga2/: file { '/etc/icinga2/': ensure => directory, @@ -99,6 +111,9 @@ class icinga2::server::config inherits icinga2::server { owner => $etc_icinga2_obejcts_owner, group => $etc_icinga2_obejcts_group, mode => $etc_icinga2_obejcts_mode, + recurse => $recurse_objects, + purge => $purge_objects, + force => $force_purge } #Directory resource for /etc/icinga2/objects/hosts/: From 75d00bf25e9bac620b424563ba98d3be8eb0c24c Mon Sep 17 00:00:00 2001 From: Nick Chappell Date: Fri, 21 Nov 2014 21:50:17 -0800 Subject: [PATCH 08/17] Added a section to the README explaining the default locations and settings for object files created by the module. --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index e2717b3..2985fc2 100644 --- a/README.md +++ b/README.md @@ -300,6 +300,16 @@ icinga2::checkplugin { 'check_diskstats': This module includes several defined types that can be used to automatically generate Icinga 2 format object definitions. They function in a similar way to [the built-in Nagios types that are included in Puppet](http://docs.puppetlabs.com/guides/exported_resources.html#exported-resources-with-nagios). +####Default object file locations, owner, group and mode + +The default file location for each object type is controlled by the `target_file_dir` parameter. For each object type, it defaults to a subdirectory under `/etc/icinga2/objects`. + +The default locations are under `/etc/icinga2/objects` and not `/etc/icinga2/conf.d/` so that user-defined objects can be kept completely separate from the objects included with Icinga 2. However, you can change the `target_file_dir` parameter to `/etc/icinga2/conf.d` if needed. + +The default file owner and group are controlled by the `target_file_owner` and `target_file_group` parameters. Both default to `root`. + +The default file mode is controlled by the `target_file_mode` parameter. It defaults to `0644`. + ####Exported resources Like the built-in Nagios types, the Icinga 2 objects in this module can be exported to PuppetDB as virtual resources and collected on your Icinga 2 server. From 97aeeec352304eab8f1b429070a15e9783be1f62 Mon Sep 17 00:00:00 2001 From: Nick Chappell Date: Fri, 21 Nov 2014 21:53:40 -0800 Subject: [PATCH 09/17] Added a section to the README about the new purge_unmanaged_object_files paramenter. --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 2985fc2..7de8f4e 100644 --- a/README.md +++ b/README.md @@ -310,6 +310,12 @@ The default file owner and group are controlled by the `target_file_owner` and ` The default file mode is controlled by the `target_file_mode` parameter. It defaults to `0644`. +####Purging unmanaged object files + +The `purge_unmanaged_object_files` parameter of the `icinga2::server` class controls whether object files in `/etc/icinga2/objects` that are not managed by Puppet get purged. It defaults to `false`. + +**Note:** This will purge unmanaged subdirectories as well as unmanaged files! + ####Exported resources Like the built-in Nagios types, the Icinga 2 objects in this module can be exported to PuppetDB as virtual resources and collected on your Icinga 2 server. From 61daba982992b1298f3a0c987b6cae3452be97e6 Mon Sep 17 00:00:00 2001 From: Nick Chappell Date: Fri, 21 Nov 2014 21:57:04 -0800 Subject: [PATCH 10/17] Added a CHANGELOG update. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea0fbd3..88072b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ * Feature: [PR-54](https://github.com/Icinga/puppet-icinga2/pull/54) and [dev.icinga.org issue #7225](https://dev.icinga.org/issues/7225): Added a CompatLogger object defined type. * Feature: [PR-55](https://github.com/Icinga/puppet-icinga2/pull/55) and [dev.icinga.org issue #7226](https://dev.icinga.org/issues/7226): Added a CheckResultReader object defined type. +* Feature: Added a parameter that controls whether to purge unmanaged files in `/etc/icinga2/objects/` ###v0.6.0 (November 19th, 2014) From 8071efdb0aa8165720cc1432deeda8840189bad5 Mon Sep 17 00:00:00 2001 From: Nick Chappell Date: Fri, 21 Nov 2014 21:59:06 -0800 Subject: [PATCH 11/17] Removed a duplicate CHANGELOG entry. --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 88072b7..67c8cbf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,7 +27,6 @@ * Feature: [PR-35](https://github.com/Icinga/puppet-icinga2/pull/35): Added the ability to use a static file or custom ERB template for check command objects * Feature: [PR-36](https://github.com/Icinga/puppet-icinga2/pull/36) and [dev.icinga.org issue #7216](https://dev.icinga.org/issues/7216): Added a [Notification](http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2#objecttype-notification) object defined type. * Feature: [PR-37](https://github.com/Icinga/puppet-icinga2/pull/37) and [dev.icinga.org issue #7217](https://dev.icinga.org/issues/7217): Added a [TimePeriod](http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2#objecttype-timeperiod) object defined type. -* Fix: [PR-42](https://github.com/Icinga/puppet-icinga2/pull/42): Fixed anchor links in the README. * Feature: [PR-39](https://github.com/Icinga/puppet-icinga2/pull/39) and [dev.icinga.org issue #7673](https://dev.icinga.org/issues/7673): Added the ability to purge non-Puppet managed NRPE config files. * Feature: [PR-41](https://github.com/Icinga/puppet-icinga2/pull/41) and [dev.icinga.org issue #7674](https://dev.icinga.org/issues/7674): Added CentOS 5 server and NRPE client support. * Fix: [PR-40](https://github.com/Icinga/puppet-icinga2/pull/40) and [dev.icinga.org issue #7675](https://dev.icinga.org/issues/7675): Escape single quotes around the `PGPASSWORD` environment variable so that single quotes can be used in the Postgres password From 00cfa7abf8739a996b987c4b6ae5dbf45c1e4235 Mon Sep 17 00:00:00 2001 From: Nick Chappell Date: Tue, 25 Nov 2014 21:27:00 -0800 Subject: [PATCH 12/17] Fix the exec resource commands so they use the new commands in 2.2 to enable/disable features instead of the old ones from 2.1 and before. refs#7714 : https://dev.icinga.org/issues/7714 --- manifests/server/features/disable.pp | 4 ++-- manifests/server/features/enable.pp | 4 ++-- manifests/server/install.pp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/manifests/server/features/disable.pp b/manifests/server/features/disable.pp index 6d73555..21a1bad 100644 --- a/manifests/server/features/disable.pp +++ b/manifests/server/features/disable.pp @@ -1,9 +1,9 @@ # Disable Icinga 2 Features/Modules define icinga2::server::features::disable () { - exec { "icinga2-disable-feature ${name}": + exec { "icinga2 disable feature ${name}": user => 'root', path => '/usr/bin:/usr/sbin:/bin/:/sbin', - command => "/usr/sbin/icinga2-disable-feature ${name}", + command => "/usr/sbin/icinga2 disable feature ${name}", unless => "[ ! -f /etc/icinga2/features-enabled/${name}.conf ]", require => Class['icinga2::server::install::packages'], } diff --git a/manifests/server/features/enable.pp b/manifests/server/features/enable.pp index 0dc0d6d..a09b1e2 100644 --- a/manifests/server/features/enable.pp +++ b/manifests/server/features/enable.pp @@ -1,9 +1,9 @@ # Enable Icinga 2 Features/Modules define icinga2::server::features::enable () { - exec { "icinga2-enable-feature ${name}": + exec { "icinga2 enable feature ${name}": user => 'root', path => '/usr/bin:/usr/sbin:/bin/:/sbin', - command => "/usr/sbin/icinga2-enable-feature ${name}", + command => "/usr/sbin/icinga2 enable feature ${name}", unless => "[ ! -f /etc/icinga2/features-available/${name}.conf ] || [ -f /etc/icinga2/features-enabled/${name}.conf ]", require => Class['icinga2::server::install::packages'], } diff --git a/manifests/server/install.pp b/manifests/server/install.pp index ad43ba2..9db78be 100644 --- a/manifests/server/install.pp +++ b/manifests/server/install.pp @@ -149,7 +149,7 @@ class icinga2::server::install::execs inherits icinga2::server { exec { 'mysql_module_enable': user => 'root', path => '/usr/bin:/usr/sbin:/bin/:/sbin', - command => '/usr/sbin/icinga2-enable-feature ido-mysql && touch /etc/icinga2/mysql_module_loaded.txt', + command => '/usr/sbin/icinga2 enable feature ido-mysql && touch /etc/icinga2/mysql_module_loaded.txt', creates => '/etc/icinga2/mysql_module_loaded.txt', require => Exec['mysql_schema_load'], } @@ -168,7 +168,7 @@ class icinga2::server::install::execs inherits icinga2::server { exec { 'postgres_module_enable': user => 'root', path => '/usr/bin:/usr/sbin:/bin/:/sbin', - command => '/usr/sbin/icinga2-enable-feature ido-pgsql && touch /etc/icinga2/postgres_module_loaded.txt', + command => '/usr/sbin/icinga2 enable feature ido-pgsql && touch /etc/icinga2/postgres_module_loaded.txt', creates => '/etc/icinga2/postgres_module_loaded.txt', require => Exec['postgres_schema_load'], } From bde5178ed182fb38572703f6ebd971f2426cffc8 Mon Sep 17 00:00:00 2001 From: Nick Chappell Date: Mon, 1 Dec 2014 19:48:55 -0800 Subject: [PATCH 13/17] Fixed a bug where features were not actually being enabled/disabled because the order of the words in the subcommands was wrong. refs#7916 : https://dev.icinga.org/issues/7916 --- manifests/server/features/disable.pp | 2 +- manifests/server/features/enable.pp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/server/features/disable.pp b/manifests/server/features/disable.pp index 21a1bad..af6564c 100644 --- a/manifests/server/features/disable.pp +++ b/manifests/server/features/disable.pp @@ -3,7 +3,7 @@ define icinga2::server::features::disable () { exec { "icinga2 disable feature ${name}": user => 'root', path => '/usr/bin:/usr/sbin:/bin/:/sbin', - command => "/usr/sbin/icinga2 disable feature ${name}", + command => "/usr/sbin/icinga2 feature disable ${name}", unless => "[ ! -f /etc/icinga2/features-enabled/${name}.conf ]", require => Class['icinga2::server::install::packages'], } diff --git a/manifests/server/features/enable.pp b/manifests/server/features/enable.pp index a09b1e2..63c11ed 100644 --- a/manifests/server/features/enable.pp +++ b/manifests/server/features/enable.pp @@ -3,7 +3,7 @@ define icinga2::server::features::enable () { exec { "icinga2 enable feature ${name}": user => 'root', path => '/usr/bin:/usr/sbin:/bin/:/sbin', - command => "/usr/sbin/icinga2 enable feature ${name}", + command => "/usr/sbin/icinga2 feature enable ${name}", unless => "[ ! -f /etc/icinga2/features-available/${name}.conf ] || [ -f /etc/icinga2/features-enabled/${name}.conf ]", require => Class['icinga2::server::install::packages'], } From 251184b944363a3464bc8fe9a950daab1f3bbf68 Mon Sep 17 00:00:00 2001 From: Nick Chappell Date: Mon, 1 Dec 2014 21:38:42 -0800 Subject: [PATCH 14/17] Added refresh_icinga2_service parameters to each of the object defined types so that they can be used by themselves if the module isn't being used to also manage the Icinga 2 service. refs# 7856 : https://dev.icinga.org/issues/7856 --- manifests/object/apply_dependency.pp | 39 +++++++--- .../object/apply_notification_to_host.pp | 37 +++++++-- .../object/apply_notification_to_service.pp | 37 +++++++-- manifests/object/apply_service_to_host.pp | 35 +++++++-- manifests/object/checkcommand.pp | 75 ++++++++++++++----- manifests/object/checkresultreader.pp | 35 +++++++-- manifests/object/compatlogger.pp | 35 +++++++-- manifests/object/dependency.pp | 37 +++++++-- manifests/object/eventcommand.pp | 35 +++++++-- manifests/object/externalcommandlistener.pp | 35 +++++++-- manifests/object/graphitewriter.pp | 37 +++++++-- manifests/object/host.pp | 36 +++++++-- manifests/object/hostgroup.pp | 36 +++++++-- manifests/object/idomysqlconnection.pp | 36 +++++++-- manifests/object/idopgsqlconnection.pp | 36 +++++++-- manifests/object/livestatuslistener.pp | 37 ++++++--- manifests/object/notification.pp | 35 +++++++-- manifests/object/notificationcommand.pp | 35 +++++++-- manifests/object/perfdatawriter.pp | 35 +++++++-- manifests/object/scheduleddowntime.pp | 36 +++++++-- manifests/object/service.pp | 36 +++++++-- manifests/object/servicegroup.pp | 36 +++++++-- manifests/object/statusdatawriter.pp | 35 +++++++-- manifests/object/sysloglogger.pp | 36 +++++++-- manifests/object/timeperiod.pp | 39 +++++++--- manifests/object/user.pp | 36 +++++++-- manifests/object/usergroup.pp | 36 +++++++-- 27 files changed, 782 insertions(+), 231 deletions(-) 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'), + } + } } From 70dffb317c2dc25da2b4ddc394f7385526b7aa19 Mon Sep 17 00:00:00 2001 From: Nick Chappell Date: Mon, 1 Dec 2014 21:42:57 -0800 Subject: [PATCH 15/17] CHANGELOG update for https://dev.icinga.org/issues/7856 refs #7856 : https://dev.icinga.org/issues/7856 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 67c8cbf..579c7fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ * Feature: [PR-54](https://github.com/Icinga/puppet-icinga2/pull/54) and [dev.icinga.org issue #7225](https://dev.icinga.org/issues/7225): Added a CompatLogger object defined type. * Feature: [PR-55](https://github.com/Icinga/puppet-icinga2/pull/55) and [dev.icinga.org issue #7226](https://dev.icinga.org/issues/7226): Added a CheckResultReader object defined type. * Feature: Added a parameter that controls whether to purge unmanaged files in `/etc/icinga2/objects/` +* Feature: [dev.icinga.org issue #7856](https://dev.icinga.org/issues/7856): Added a parameter to each object defined type that can controle whether the Icinga 2 service gets refreshed; it can be set to false if the module is being used to just generate object definition files and isn't managing the service ###v0.6.0 (November 19th, 2014) From 702f20974fea1ad30c458c18c9ab44acb2efee8e Mon Sep 17 00:00:00 2001 From: Nick Chappell Date: Mon, 1 Dec 2014 21:49:33 -0800 Subject: [PATCH 16/17] Added a README note about the refresh_icinga2_service parameter. refs#7856 : https://dev.icinga.org/issues/7856 --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index 7de8f4e..779a381 100644 --- a/README.md +++ b/README.md @@ -373,6 +373,21 @@ This means that they will not be added to the rendered object definition files. **However**, this doesn't mean that the values are undefined in Icinga 2. Icinga 2 itself has built-in default values for many object parameters and falls back to them if one isn't present in an object definition. See the docs for individual object types in [Configuring Icinga 2](http://docs.icinga.org/icinga2/latest/doc/module/icinga2/toc#!/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2) for more info about which object parameters have what default values. +####Notifying the Icinga 2 service + +By default, each object defined type will automatically notify and restart the Icinga 2 service. However, if you're using the module to just generate object files and not using it to manage the service, you'll likely get compilation errors about the `icinga2` service not being in the catalog. + +Each object defined type has a boolean parameter, `refresh_icinga2_service`, that controls whether the object file will notify the service. To **not** notify the service, set it to `false`: + +
+icinga2::object::apply_dependency { 'usermail_dep_on_icinga2mail':
+  parent_host_name => 'icinga2mail.local',
+  target_file_owner => vagrant,
+  assign_where => 'match("^usermail*", host.name)',
+  refresh_icinga2_service => false,
+}
+
+ ####[Objects](id:objects) Object types: From 30a93e44d43b4d976cee4266da60a1fdb1857f98 Mon Sep 17 00:00:00 2001 From: Nick Chappell Date: Tue, 2 Dec 2014 21:41:01 -0800 Subject: [PATCH 17/17] CHANGELOG release version date. --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 579c7fc..e864f43 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ #Changelog - - - -###v0.6.1 (unreleased) +###v0.6.1 (December 2nd, 2014) * Feature: [PR-54](https://github.com/Icinga/puppet-icinga2/pull/54) and [dev.icinga.org issue #7225](https://dev.icinga.org/issues/7225): Added a CompatLogger object defined type. * Feature: [PR-55](https://github.com/Icinga/puppet-icinga2/pull/55) and [dev.icinga.org issue #7226](https://dev.icinga.org/issues/7226): Added a CheckResultReader object defined type.