Merge remote-tracking branch 'upstream/master' into 7222

This commit is contained in:
ricardo@cropalato.com.br 2014-11-17 06:25:50 -05:00
commit 58edf35726
5 changed files with 261 additions and 2 deletions

View file

@ -356,6 +356,7 @@ Object types:
* [icinga2::object::applyservicetohost](#icinga2objectapplyservicetohost)
* [icinga2::object::applynotificationtohost](#icinga2objectapplynotificationtohost)
* [icinga2::object::applynotificationtoservice](#icinga2objectapplynotificationtoservice)
* [icinga2::object::checkcommand](#icinga2objectcheckcommand)
* [icinga2::object::eventcommand](#icinga2objecteventcommand)
* [icinga2::object::host](#icinga2objecthost)
@ -366,6 +367,7 @@ Object types:
* [icinga2::object::notification](#icinga2objectnotification)
* [icinga2::object::notificationcommand](#icinga2objectnotificationcommand)
* [icinga2::object::perfdatawriter](#icinga2objectperfdatawriter)
* [icinga2::object::scheduleddowntime](#icinga2objectscheduleddowntime)
* [icinga2::object::service](#icinga2objectservice)
* [icinga2::object::servicegroup](#icinga2objectservicegroup)
* [icinga2::object::syslogger](#icinga2objectsyslogger)
@ -423,6 +425,23 @@ icinga2::object::apply_notification_to_host { 'pagerduty-host':
}
````
####[`icinga2::object::applynotificationtoservice`](id:object_apply_notification_to_service)
The `apply_notification_to_service` defined type can create `apply` objects to apply notifications to service:
This defined type has the same available attributes that the `icinga2::object::notification` defined type does. With the addition of assign_where and ignore_where
````
icinga2::object::apply_notification_to_service { 'pagerduty-service':
assign_where => 'service.vars.enable_pagerduty == "true"',
command => 'notify-service-by-pagerduty',
users => [ 'pagerduty' ],
states => [ 'OK', 'Warning', 'Critical', 'Unknown' ],
types => [ 'Problem', 'Acknowledgement', 'Recovery', 'Custom' ],
period => '24x7',
}
````
####[`icinga2::object::checkcommand`](id:object_checkcommand)
The `checkcommand` defined type can create `checkcommand` objects.
@ -686,8 +705,7 @@ This object use the same parameter defined to `checkcommand`.
####[`icinga2::object::perfdatawriter`](id:object_perfdatawriter)
This dfined type creates a **PerfdataWriter** object
This defined type creates a **PerfdataWriter** object
Example usage:
<pre>
@ -702,6 +720,22 @@ icinga2::object::perfdatawriter { 'pnp':
See [PerfdataWriter](http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2#objecttype-perfdatawriter) on [docs.icinga.org](http://docs.icinga.org/icinga2/latest/doc/module/icinga2/toc) for a full list of parameters.
####[`icinga2::object::scheduleddowntime`](id:object_scheduleddowntime)
This defined type creates **ScheduledDowntime** objects
<pre>
icinga2::object::scheduleddowntime {'some-downtime':
host_name => 'localhost',
service_name => 'ping4',
author => 'icingaadmin',
comment => 'Some comment',
fixed => false,
duration => '30m',
ranges => { 'sunday' => '02:00-03:00' }
}
</pre>
####[`icinga2::object::service`](id:object_service)
Coming soon...

View file

@ -0,0 +1,66 @@
# == Defined type: icinga2::object::apply_notification_to_service
#
# This is a defined type for Icinga 2 apply dependency objects.
# See the following Icinga 2 doc page for more info:
# http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2#objecttype-notification
# http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2#apply
#
# === Parameters
#
# See the inline comments.
#
define icinga2::object::apply_notification_to_service (
$object_notificationname = $name,
$host_name = undef,
$notification_to_import = undef,
$assign_where = undef,
$ignore_where = undef,
$command = undef,
$vars = {},
$users = [],
$user_groups = [],
$times = {},
$interval = undef,
$period = undef,
$types = [],
$states = [],
$target_dir = '/etc/icinga2/objects/applys',
$target_file_name = "${name}.conf",
$target_file_owner = 'root',
$target_file_group = 'root',
$target_file_mode = '0644'
) {
#Do some validation of the class' parameters:
validate_string($object_notificationname)
validate_string($host_name)
validate_string($notification_to_import)
validate_string($command)
validate_hash($vars)
validate_array($users)
validate_array($user_groups)
validate_hash($times)
if $interval {
validate_re($interval, '^\d$')
}
if $period {
validate_string($period)
}
validate_array($types)
validate_array($states)
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 => file,
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'],
}
}

View file

@ -0,0 +1,54 @@
# == Defined type: icinga2::object::scheduleddowntime
#
# This is a defined type for Icinga 2 ScheduledDowntime objects.
# See the following Icinga 2 doc page for more info:
# http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2#objecttype-scheduleddowntime
#
# === Parameters
#
# See the inline comments.
#
define icinga2::object::scheduleddowntime (
$object_scheduleddowntimename = $name,
$host_name = undef,
$service_name = undef,
$author = undef,
$comment = undef,
$fixed = true,
$duration = undef,
$ranges = {},
$target_dir = '/etc/icinga2/objects/scheduleddowntimes',
$target_file_name = "${name}.conf",
$target_file_owner = 'root',
$target_file_group = 'root',
$target_file_mode = '0644'
) {
#Do some validation of the define's parameters:
validate_string($object_scheduleddowntimename)
validate_string($host_name)
if $service_name {
validate_string($service_name)
}
validate_string($author)
validate_string($comment)
validate_bool($fixed)
validate_string($duration)
validate_hash($ranges)
validate_string($target_dir)
validate_string($target_file_name)
validate_string($target_file_owner)
validate_string($target_file_group)
validate_string($target_file_mode)
file {"${target_dir}/${target_file_name}":
ensure => file,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_scheduleddowntime.conf.erb'),
notify => Service['icinga2'],
}
}

View file

@ -0,0 +1,67 @@
/**
* WARNING: This service definition is automatically generated by Puppet.
* ANY MANUAL CHANGES TO IT WILL GET OVERWRITTEN!
*/
/**
* A object definition that applys notifications to hosts. You can create your
* own configuration files in the conf.d directory (e.g. one per host).
* By default all *.conf files in this directory are included.
*
*/
apply Notification "<%= @object_notificationname %>" to Service {
<%#- If any of the @ parameters are undefined, don't print anything for them: -%>
<%- if @notification_to_import -%>
<%#- Otherwise, include the parameter: -%>
import "<%= @notification_to_import %>"
<%- end -%>
<%- if @host_name -%>
host_name = "<%= @host_name %>"
<%- end -%>
<%- if @assign_where -%>
assign where <%= @assign_where %>
<%- end -%>
<%- if @ignore_where -%>
ignore where <%= @ignore_where %>
<%- end -%>
<%- if @command -%>
command = "<%= @command %>"
<%- end -%>
<%- if @vars.empty? != true -%>
<%- @vars.each_pair do |key,value| -%>
<%= key %> = <% if value.class == String %><%= value %>
<%- else -%>{
<%- value.each_pair do |k,v| -%>
<%= k %> = <%= v %>
<%- end -%>
}
<%- end -%>
<%- end -%>
<%- end -%>
<%- if @users.empty? !=true -%>
users = [ <% @users.each_with_index do |usr, i| %>"<%= usr -%>"<%= ', ' if i < (@users.size - 1) %><% end %> ]
<%- end -%>
<%- if @user_groups.empty? !=true -%>
user_groups = [ <% @user_groups.each_with_index do |u_grp, i| %>"<%= u_grp -%>"<%= ', ' if i < (@user_groups.size - 1) %><% end %> ]
<%- end -%>
<%- if @times.empty? != true -%>
times = {
<%- @times.each_pair do |key,value| -%>
<%= key %> = "<%= value %>"
<%- end -%>
}
<%- end -%>
<%- if @interval -%>
interval = "<%= @inteval -%>"
<%- end -%>
<%- if @period -%>
period = "<%= @period -%>"
<%- end -%>
<%- if @types.empty? !=true -%>
types = [ <% @types.each_with_index do |typ, i| %><%= typ -%><%= ', ' if i < (@types.size - 1) %><% end %> ]
<%- end -%>
<%- if @states.empty? !=true -%>
states = [ <% @states.each_with_index do |state, i| %><%= state -%><%= ', ' if i < (@states.size - 1) %><% end %> ]
<%- end -%>
}

View file

@ -0,0 +1,38 @@
/**
* WARNING: This scheduleddowntime definition is automatically generated by Puppet.
* ANY MANUAL CHANGES TO IT WILL GET OVERWRITTEN!
*/
/**
* A ScheduledDowntime definition. You can create your own configuration files
* in the conf.d directory (e.g. one per host). By default all *.conf
* files in this directory are included.
*
*/
object ScheduledDowntime "<%= @object_scheduleddowntimename %>" {
<%#- If any of the @ parameters are undefined, don't print anything for them: -%>
host_name = "<%= @host_name -%>"
<%- if @service_name -%>
service_name = "<%= @service_name -%>"
<%- end -%>
author = "<%= @author -%>"
comment = "<%= @comment -%>"
<%- if @fixed != true -%>
fixed = false
<%- end -%>
<%- if @duration -%>
duration = <%= @duration -%>
<%- end -%>
<%- if @ranges.empty? != true -%>
ranges = {
<%- @ranges.each_pair do |key, value| -%>
"<%= key %>" = "<%= value %>"
<%- end -%>
}
<%- end -%>
}