From caafad45ea8d3293aa18a878f09eb1f938bce55d Mon Sep 17 00:00:00 2001 From: "ricardo@cropalato.com.br" Date: Wed, 26 Nov 2014 08:19:27 -0500 Subject: [PATCH] Adding IcingaStatusWriter object. #7230 --- README.md | 15 +++++++ manifests/object/icingastatuswriter.pp | 44 ++++++++++++++++++++ templates/object_icingastatuswriter.conf.erb | 20 +++++++++ 3 files changed, 79 insertions(+) create mode 100644 manifests/object/icingastatuswriter.pp create mode 100644 templates/object_icingastatuswriter.conf.erb diff --git a/README.md b/README.md index 7de8f4e..27334d0 100644 --- a/README.md +++ b/README.md @@ -387,6 +387,7 @@ Object types: * [icinga2::object::externalcommandlistener](#icinga2objectexternalcommandlistener) * [icinga2::object::host](#icinga2objecthost) * [icinga2::object::hostgroup](#icinga2objecthostgroup) +* [icinga2::object::icingastatuswriter](#icinga2objecticingastatuswriter) * [icinga2::object::idomysqlconnection](#icinga2objectidomysqlconnection) * [icinga2::object::idopgsqlconnection](#icinga2objectidopgsqlconnection) * [icinga2::object::livestatuslistener](#icinga2objectlivestatuslistener) @@ -620,6 +621,20 @@ If you would like to use an IPv6 address, make sure to set the `ipv6_address` pa Coming soon... +####[`icinga2::object::icingastatuswriter`](id:object_icingastatuswriter) + +This defined type creates an **IcingaStatusWriter** objects. + +Example usage: +
+icinga2::object::icingastatuswriter { 'status':
+   status_path       => '/cache/icinga2/status.json',
+   update_interval   => '15s',
+}
+
+ +See [IcingaStatusWriter](http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2#objecttype-icingastatuswriter) on [docs.icinga.org](http://docs.icinga.org/icinga2/latest/doc/module/icinga2/toc) for more details about the object. + ####[`icinga2::object::idomysqlconnection`](id:object_idomysqlconnection) This defined type creates an **IdoMySqlConnection** objects. diff --git a/manifests/object/icingastatuswriter.pp b/manifests/object/icingastatuswriter.pp new file mode 100644 index 0000000..61fdb69 --- /dev/null +++ b/manifests/object/icingastatuswriter.pp @@ -0,0 +1,44 @@ +# == Defined type: icinga2::object::icingastatuswriter +# +# This is a defined type for Icinga 2 apply objects that create IcingaStatusWriter +# See the following Icinga 2 doc page for more info: +# http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2#objecttype-checkercomponent +# +# === Parameters +# +# See the inline comments. +# + +define icinga2::object::icingastatuswriter ( + $ensure = 'file', + $object_name = $name, + $status_path = undef, + $update_internal = undef, + $target_dir = '/etc/icinga2/objects/icingastatuswriters', + $target_file_name = "${name}.conf", + $target_file_owner = 'root', + $target_file_group = 'root', + $target_file_mode = '0644' +) { + + if $status_path { + validate_string($status_path) + } + if $update_internal { + validate_string($update_internal) + } + 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_icingastatuswriter.conf.erb'), + notify => Service['icinga2'], + } +} diff --git a/templates/object_icingastatuswriter.conf.erb b/templates/object_icingastatuswriter.conf.erb new file mode 100644 index 0000000..6dad90f --- /dev/null +++ b/templates/object_icingastatuswriter.conf.erb @@ -0,0 +1,20 @@ +/** +* WARNING: This IcingaStatusWriter is automatically generated by Puppet. +* ANY MANUAL CHANGES TO IT WILL GET OVERWRITTEN! +*/ + +/** +* A IcingaStatusWriter 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. +* +*/ + +object IcingaStatusWriter "<%= @object_name %>" { +<%- if @status_path -%> + status_path = LocalStateDir + "<%= @status_path -%>" +<%- end -%> +<%- if @update_interval -%> + update_interval = <%= @update_interval -%> +<%- end -%> +}