diff --git a/README.md b/README.md index 82f50ca..32f2807 100644 --- a/README.md +++ b/README.md @@ -437,6 +437,7 @@ Object types: * [icinga2::object::livestatuslistener](#icinga2objectlivestatuslistener) * [icinga2::object::notification](#icinga2objectnotification) * [icinga2::object::notificationcommand](#icinga2objectnotificationcommand) +* [icinga2::object::notificationcomponent](#icinga2objectnotificationcomponent) * [icinga2::object::perfdatawriter](#icinga2objectperfdatawriter) * [icinga2::object::scheduleddowntime](#icinga2objectscheduleddowntime) * [icinga2::object::service](#icinga2objectservice) @@ -873,6 +874,30 @@ icinga2::object::notificationcommand { 'mail-service-notification': This object use the same parameter defined to `checkcommand`. +####[`icinga2::object::notificationcomponent`](id:object_notificationcomponent) + +The `notificationcomponent` defined type can create `notificationcomponent` objects. + +Example: + +
+icinga2::object::notificationcomponent {'notification':} ++ +This object support the following parameters: +* `ensure` - Optional parameter used to remove or create the file, Default value is 'file'. Use 'absent' to remove the file. +* `object_name` - Optional. Used to define file name. default value is 'checker' +* `enable_ha` - Optional. Enable the high availability functionality. Only valid in a cluster setup. Default value is true. +* `target_dir` - Optional. Define where the conf fil will be created. Default value is '/etc/icinga2/features-avalable' +* `target_file_name` - Optional. Define the file name. Default value is '${object_name}.conf'. +* `target_file_owner` - Optional. File Owner. Default value is 'root'. +* `target_file_group` - Optional. File Group. Default value is 'root'. +* `target_file_mode` - Optional. File Mode. Default value is '0644'. + +See [NotificationComponent](http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2#objecttype-notificationcomponent) on [docs.icinga.org](http://docs.icinga.org/icinga2/latest/doc/module/icinga2/toc) for more details about this object. + +Should be enable/disable using `icinga2::server::features::enable` or `icinga2::server::features::disable`. + ####[`icinga2::object::perfdatawriter`](id:object_perfdatawriter) This defined type creates a **PerfdataWriter** object diff --git a/manifests/object/notificationcomponent.pp b/manifests/object/notificationcomponent.pp new file mode 100644 index 0000000..9c8dec0 --- /dev/null +++ b/manifests/object/notificationcomponent.pp @@ -0,0 +1,40 @@ +# == Defined type: icinga2::object::notificationcomponent +# +# This is a defined type for Icinga 2 apply objects that create Notification Component +# See the following Icinga 2 doc page for more info: +# http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2#objecttype-notificationcomponent +# +# === Parameters +# +# See the inline comments. +# + +define icinga2::object::notificationcomponent ( + $ensure = 'file', + $object_name = $name, + $enable_ha = undef, + $target_dir = '/etc/icinga2/features-avalable', + $target_file_name = "${name}.conf", + $target_file_owner = 'root', + $target_file_group = 'root', + $target_file_mode = '0644' +) { + + if $enable_ha { + validate_bool($enable_ha) + } + 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 => $ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_notificationcomponent.conf.erb'), +# notify => Service['icinga2'], # Dont need to reload/restart the service only enable/disable the feature. Should we force enable/disable the feature (icinga2 feature enable notification) or should the user define it? + } +} diff --git a/templates/object_notificationcomponent.conf.erb b/templates/object_notificationcomponent.conf.erb new file mode 100644 index 0000000..c288e7e --- /dev/null +++ b/templates/object_notificationcomponent.conf.erb @@ -0,0 +1,19 @@ +/** +* WARNING: This NotificationComponent is automatically generated by Puppet. +* ANY MANUAL CHANGES TO IT WILL GET OVERWRITTEN! +*/ + +/** +* A NotificationComponent 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 "notification" + +object NotificationComponent "<%= @object_name %>" { + <%- if @enable_ha != true -%> + enable_ha = false + <%- end -%> +}