Adding EndPoint Object. #7232

Merged from: https://github.com/Icinga/puppet-icinga2/pull/63

refs#7232: https://dev.icinga.org/issues/7232
This commit is contained in:
ricardo@cropalato.com.br 2014-11-26 08:44:15 -05:00 committed by Nick Chappell
parent ce3bd25fe9
commit 6646b3b392
3 changed files with 81 additions and 0 deletions

View file

@ -398,6 +398,7 @@ Object types:
* [icinga2::object::checkcommand](#icinga2objectcheckcommand)
* [icinga2::object::compatlogger](#icinga2objectcompatlogger)
* [icinga2::object::checkresultreader](#icinga2objectcheckresultreader)
* [icinga2::object::endpoint](#icinga2objectendpoint)
* [icinga2::object::eventcommand](#icinga2objecteventcommand)
* [icinga2::object::externalcommandlistener](#icinga2objectexternalcommandlistener)
* [icinga2::object::host](#icinga2objecthost)
@ -567,6 +568,19 @@ icinga2::object::checkresultreader {'reader':
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::endpoint]`(id:object_endpoint)
The `endpoint` defined type can create `endpoint` objects.
<pre>
icinga2::object::endpoint { 'icinga2b':
host => '192.168.5.46',
port => 5665
}
</pre>
See [EndPoint](http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2#objecttype-endpoint) 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.

View file

@ -0,0 +1,46 @@
# == Defined type: icinga2::object::endpoint
#
# This is a defined type for Icinga 2 apply objects that create EndPoint
# See the following Icinga 2 doc page for more info:
# http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2#objecttype-endpoint
#
# === Parameters
#
# See the inline comments.
#
define icinga2::object::endpoint (
$ensure = 'file',
$object_name = $name,
$host = undef,
$port = undef,
$log_duration = undef,
$target_dir = '/etc/icinga2/object/endpoints',
$target_file_name = "${object_name}.conf",
$target_file_owner = 'root',
$target_file_group = 'root',
$target_file_mode = '0644'
) {
validate_string($host)
if $port {
validate_re($port, '^\d{1,5}$')
}
if $log_duration {
validate_string($log_duration)
}
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_endpoint.conf.erb'),
notify => Service['icinga2'],
}
}

View file

@ -0,0 +1,21 @@
/**
* WARNING: This EndPoint is automatically generated by Puppet.
* ANY MANUAL CHANGES TO IT WILL GET OVERWRITTEN!
*/
/**
* A EndPoint 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 EndPoint "<%= @object_name %>" {
host = "<%= @host -%>"
<%- if @port -%>
port = <%= @port -%>
<%- end -%>
<%- if @log_duration -%>
log_duration = <%= @log_duration -%>
<%- end -%>
}