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

This commit is contained in:
ricardo@cropalato.com.br 2014-11-16 09:23:55 -05:00
commit 14925ea9ef
12 changed files with 360 additions and 14 deletions

View file

@ -5,3 +5,7 @@ Michael Friedrich <michael.friedrich@netways.de>
Nick Chappell <nick@intronic.org>
Thomas Weißschuh <thomas@t-8ch.de>
Steven Bambling <smbambling@gmail.com>
Josh Holland <josh@inv.alid.pw>
Ricardo Melo <ricardo.melo@gameloft.com>
Tom De Vylder
Devon Mizelle <devon@arin.net>

View file

@ -22,7 +22,13 @@
* 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
* Fix: [PR-42](https://github.com/Icinga/puppet-icinga2/pull/42): Fix anchor links in the README
* Feature: [PR-43](https://github.com/Icinga/puppet-icinga2/pull/43) and [dev.icinga.org issue #7676](https://dev.icinga.org/issues/7676): Created an object to apply notifications to hosts
* Feature: [PR-45](https://github.com/Icinga/puppet-icinga2/pull/45) and [dev.icinga.org issue #7220](https://dev.icinga.org/issues/7220): Created an object defined type for PerfDataWriter objects
* Feature: [PR-46](https://github.com/Icinga/puppet-icinga2/pull/46) and [dev.icinga.org issue #7222](https://dev.icinga.org/issues/7222): Created an object defined type for LivestatusListener objects
###v0.5 (August 17th, 2014)

View file

@ -36,7 +36,7 @@ This module requires the [Puppet Labs stdlib module](https://github.com/puppetla
For Ubuntu systems, this module requires the [Puppet Labs apt module](https://github.com/puppetlabs/puppetlabs-apt).
On EL-based systems (CentOS, Red Hat Enterprise Linux, Fedora, etc.), the [EPEL package repository](https://fedoraproject.org/wiki/EPEL) is required.
On EL-based systems (CentOS, Red Hat Enterprise Linux, Fedora, etc.), the [EPEL package repository](https://fedoraproject.org/wiki/EPEL) is required. You can also use the [icinga2::nrpe class](#nrpe-usage) to set up NRPE on CentOS 5. It is discouraged to set up Icinga2 Server on this old of a distribution. You are encouraged to use at least CentOS 6 or higher.
If you would like to use the `icinga2::object` defined types as [exported resources](https://docs.puppetlabs.com/guides/exported_resources.html), you'll need to have your Puppet master set up with PuppetDB. See the Puppet Labs documentation for more info: [Docs: PuppetDB](https://docs.puppetlabs.com/puppetdb/)
@ -61,6 +61,24 @@ The example below shows the [Puppet Labs Postgres module](https://github.com/pup
For production use, you'll probably want to get the database password via a [Hiera lookup](http://docs.puppetlabs.com/hiera/1/puppet.html) so the password isn't sitting in your site manifests in plain text.
####Note For CentOS 5
You must be running CentOS 5.11 and _no later_ in order to satisfy dependencies.
If you are attempting to install Icinga2 server on CentOS 5 (discouraged) and would like to use PostgreSQL, you must provide a non-EOL'd version of it. If you are installing PostgreSQL for the first time, you can tell the module to manage the pgsql YUM repository like so:
<pre>
class { 'postgresql::globals':
manage_package_repo => true,
version => '9.3',
}->
class { 'postgresql::server': }
</pre>
CentOS 5 provides PostgreSQL 9.1 by default, which was end-of-life'd in 2010. Without having the module manage the repo, it will gladly install this crippled version for you which isn't what you want.
**You will still need to declare a database for Icinga2 to access.**
[Usage](id:usage)
-----
@ -70,7 +88,7 @@ For production use, you'll probably want to get the database password via a [Hie
This defined type creates custom files in the `/etc/icinga2/conf.d` directory.
The `icinga2::conf` type has `target_dir`, `target_file_name`, `target_file_owner`, `target_file_group` and `target_file_mode` parameters just like the `icinga2::object` types.
The `icinga2::conf` type has `target_dir`, `target_file_name`, `target_file_owner`, `target_file_group` and `target_file_mode` parameters just like the `icinga2::object` types.
The content of the file can be managed with two parameters:
@ -102,10 +120,10 @@ Once the database is set up, use the `icinga2::server` class with the database c
#Install Icinga 2:
class { 'icinga2::server':
server_db_type => 'pgsql',
db_host => 'localhost'
db_port => '5432'
db_name => 'icinga2_data'
db_user => 'icinga2'
db_host => 'localhost',
db_port => '5432',
db_name => 'icinga2_data',
db_user => 'icinga2',
db_password => 'password',
}
</pre>
@ -118,10 +136,10 @@ When the `server_db_type` parameter is set, the right IDO database connection pa
#Install Icinga 2:
class { 'icinga2::server':
server_db_type => 'pgsql',
db_host => 'localhost'
db_port => '5432'
db_name => 'icinga2_data'
db_user => 'icinga2'
db_host => 'localhost',
db_port => '5432',
db_name => 'icinga2_data',
db_user => 'icinga2',
db_password => hiera('icinga_db_password_key_here'),
}
</pre>
@ -225,6 +243,14 @@ class { 'icinga2::nrpe':
}
````
If you'd like to purge NRPE config files that are not managed by Puppet you can set $nrpe_purge_unmanaged to true.
```
class { 'icinga2::nrpe':
nrpe_purge_unmanaged => true,
}
```
**Note:** If you would like to install NRPE on a node that also has the `icinga2::server` class applied, be sure to set the `$server_install_nagios_plugins` parameter in your call to `icinga2::server` to `false`:
<pre>
@ -329,6 +355,7 @@ This means that they will not be added to the rendered object definition files.
Object types:
* [icinga2::object::applyservicetohost](#icinga2objectapplyservicetohost)
* [icinga2::object::applynotificationtohost](#icinga2objectapplynotificationtohost)
* [icinga2::object::checkcommand](#icinga2objectcheckcommand)
* [icinga2::object::eventcommand](#icinga2objecteventcommand)
* [icinga2::object::externalcommandlistener](#icinga2objectexternalcommandlistener)
@ -338,6 +365,7 @@ Object types:
* [icinga2::object::idopgsqlconnection](#icinga2objectidopgsqlconnection)
* [icinga2::object::notification](#icinga2objectnotification)
* [icinga2::object::notificationcommand](#icinga2objectnotificationcommand)
* [icinga2::object::perfdatawriter](#icinga2objectperfdatawriter)
* [icinga2::object::service](#icinga2objectservice)
* [icinga2::object::servicegroup](#icinga2objectservicegroup)
* [icinga2::object::syslogger](#icinga2objectsyslogger)
@ -377,6 +405,24 @@ If you would like to use Puppet or Facter variables in an `assign_where` or `ign
assign_where => "\"linux_servers\" in host.${facter_variable}"",
</pre>
####[`icinga2::object::applynotificationtohost`](id:object_apply_notification_to_host)
The `apply_notification_to_host` defined type can create `apply` objects to apply notifications to hosts:
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
````
#Create an apply that will send notifications to PagerDuty
icinga2::object::apply_notification_to_host { 'pagerduty-host':
assign_where => 'host.vars.enable_pagerduty == "true"',
command => 'notify-host-by-pagerduty',
users => [ 'pagerduty' ],
states => [ 'Up', 'Down' ],
types => [ 'Problem', 'Acknowledgement', 'Recovery', 'Custom' ],
period => '24x7',
}
````
####[`icinga2::object::checkcommand`](id:object_checkcommand)
The `checkcommand` defined type can create `checkcommand` objects.
@ -636,6 +682,24 @@ icinga2::object::notificationcommand { 'mail-service-notification':
This object use the same parameter defined to `checkcommand`.
####[`icinga2::object::perfdatawriter`](id:object_perfdatawriter)
This dfined type creates a **PerfdataWriter** object
Example usage:
<pre>
icinga2::object::perfdatawriter { 'pnp':
host_perfdata_path => '/var/spool/icinga2/perfdata/host-perfdata',
service_perfdata_path => '/var/spool/icinga2/perfdata/service-perfdata',
host_format_template => 'DATATYPE::HOSTPERFDATA\tTIMET::$icinga.timet$\tHOSTNAME::$host.name$\tHOSTPERFDATA::$host.perfdata$\tHOSTCHECKCOMMAND::$host.check_command$\tHOSTSTATE::$host.state$\tHOSTSTATETYPE::$host.state_type$',
service_format_template => 'DATATYPE::SERVICEPERFDATA\tTIMET::$icinga.timet$\tHOSTNAME::$host.name$\tSERVICEDESC::$service.name$\tSERVICEPERFDATA::$service.perfdata$\tSERVICECHECKCOMMAND::$service.check_command$\tHOSTSTATE::$host.state$\tHOSTSTATETYPE::$host.state_type$\tSERVICESTATE::$service.state$\tSERVICESTATETYPE::$service.state_type$',
rotation_interval => '15s'
}
</pre>
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::service`](id:object_service)
Coming soon...
@ -659,7 +723,7 @@ See [ServiceGroup](http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chap
This defined type creates **SyslogLogger** objects.
`severity` can be set to **debug**, **notice**, **information**, **warning** or **critical**.
`severity` can be set to **debug**, **notice**, **information**, **warning** or **critical**.
Example usage:
@ -748,7 +812,7 @@ Coming soon...
###Contributing
To submit a pull request via Github, fork [Icinga/puppet-icinga2](https://github.com/Icinga/puppet-icinga2) and make your changes in a feature branch off of the master branch.
To submit a pull request via Github, fork [Icinga/puppet-icinga2](https://github.com/Icinga/puppet-icinga2) and make your changes in a feature branch off of the master branch.
If your changes require any discussion, create an account on [https://www.icinga.org/register/](https://www.icinga.org/register/). Once you have an account, log onto [dev.icinga.org](https://dev.icinga.org/). Create an issue under the **Icinga Tools** project and add it to the **Puppet** category.

View file

@ -13,6 +13,7 @@ class icinga2::nrpe (
$nrpe_connection_timeout = $icinga2::params::nrpe_connection_timeout,
$nrpe_allowed_hosts = $icinga2::params::nrpe_allowed_hosts,
$nrpe_allow_command_argument_processing = $icinga2::params::allow_command_argument_processing,
$nrpe_purge_unmanaged = $icinga2::params::nrpe_purge_unmanaged,
) inherits icinga2::params {

View file

@ -24,6 +24,18 @@ class icinga2::nrpe::config inherits icinga2::nrpe {
owner => 'root',
group => 'root',
mode => '0755',
purge => $nrpe_purge_unmanaged,
recurse => true,
require => Package[$icinga2::params::icinga2_client_packages],
}
file { '/etc/nrpe.d':
ensure => directory,
owner => 'root',
group => 'root',
mode => '0755',
purge => $nrpe_purge_unmanaged,
recurse => true,
require => Package[$icinga2::params::icinga2_client_packages],
}

View file

@ -0,0 +1,64 @@
# == Defined type: icinga2::object::apply_dependency
#
# 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_host (
$object_notificationname = $name,
$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($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_host.conf.erb'),
notify => Service['icinga2'],
}
}

View file

@ -0,0 +1,70 @@
# == Defined type: icinga2::object::perfdatawriter
#
# This is a defined type for Icinga 2 apply objects that create Perfdata Writer
# See the following Icinga 2 doc page for more info:
# http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2#objecttype-perfdatawriter
#
# === Parameters
#
# See the inline comments.
#
define icinga2::object::perfdatawriter (
$ensure = 'file',
$object_perfdatawritername = $name,
$host_perfdata_path = undef,
$service_perfdata_path = undef,
$host_temp_path = undef,
$service_temp_path = undef,
$host_format_template = undef,
$service_format_template = undef,
$rotation_interval = undef,
$target_dir = '/etc/icinga2/objects/perfdatawriters',
$target_file_name = "${name}.conf",
$target_file_owner = 'root',
$target_file_group = 'root',
$target_file_mode = '0644'
) {
#Do some validation of the class' parameters:
if $object_perfdatawritername {
validate_string($object_perfdatawritername)
}
if $host_perfdata_path {
validate_string($host_perfdata_path)
}
if $service_perfdata_path {
validate_string($service_perfdata_path)
}
if $host_temp_path {
validate_string($host_temp_path)
}
if $service_temp_path {
validate_string($service_temp_path)
}
if $host_format_template {
validate_string($host_format_template)
}
if $service_format_template {
validate_string($service_format_template)
}
if $rotation_interval {
validate_string($rotation_interval)
}
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_perfdatawriter.conf.erb'),
notify => Service['icinga2'],
}
}

View file

@ -72,6 +72,12 @@ class icinga2::params {
#CentOS systems:
'CentOS': {
case $::operatingsystemmajrelease {
'5': {
#Icinga 2 server package
$icinga2_server_package = 'icinga2'
$icinga2_server_plugin_packages = ['nagios-plugins-nrpe', 'nagios-plugins-all', 'nagios-plugins-openmanage', 'nagios-plugins-check-updates']
$icinga2_server_mail_package = 'mailx'
}
'6': {
#Icinga 2 server package
$icinga2_server_package = 'icinga2'
@ -237,6 +243,9 @@ class icinga2::params {
#Icinga 2 server daemon names for Red Had/CentOS systems:
'CentOS': {
case $::operatingsystemmajrelease {
'5': {
$icinga2_server_service_name = 'icinga2'
}
'6': {
$icinga2_server_service_name = 'icinga2'
}
@ -297,6 +306,9 @@ class icinga2::params {
# Defaults to NOT allow command arguments
$allow_command_argument_processing = '0'
# Whether or not to purge nrpe config files NOT managed by Puppet.
$nrpe_purge_unmanaged = false
case $::operatingsystem {
#File and template variable names for Red Had/CentOS systems:
'CentOS': {
@ -335,6 +347,10 @@ class icinga2::params {
#CentOS systems:
'CentOS': {
case $::operatingsystemmajrelease {
'5': {
#Pick the right list of client packages:
$icinga2_client_packages = ['nrpe', 'nagios-plugins-nrpe', 'nagios-plugins-all', 'nagios-plugins-openmanage', 'nagios-plugins-check-updates']
}
'6': {
#Pick the right list of client packages:
$icinga2_client_packages = ['nrpe', 'nagios-plugins-nrpe', 'nagios-plugins-all', 'nagios-plugins-openmanage', 'nagios-plugins-check-updates']

View file

@ -160,7 +160,7 @@ class icinga2::server::install::execs inherits icinga2::server {
exec { 'postgres_schema_load':
user => 'root',
path => '/usr/bin:/usr/sbin:/bin/:/sbin',
command => "su - postgres -c 'export PGPASSWORD='${db_password}' && psql -U ${db_user} -h localhost -d ${db_name} < ${server_db_schema_path}' && export PGPASSWORD='' && touch /etc/icinga2/postgres_schema_loaded.txt",
command => "su - postgres -c 'export PGPASSWORD='\\''${db_password}'\\'' && psql -U ${db_user} -h localhost -d ${db_name} < ${server_db_schema_path}' && export PGPASSWORD='' && touch /etc/icinga2/postgres_schema_loaded.txt",
creates => '/etc/icinga2/postgres_schema_loaded.txt',
require => Class['icinga2::server::install::packages'],
}

View file

@ -11,6 +11,7 @@
{
"operatingsystem": "CentOS",
"operatingsystemmajrelease": [
"5",
"6",
"7"
]

View file

@ -0,0 +1,64 @@
/**
* 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 Host {
<%#- 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 @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,44 @@
/**
* WARNING: This PerfdataWtiter definition is automatically generated by Puppet.
* ANY MANUAL CHANGES TO IT WILL GET OVERWRITTEN!
*/
/**
* A PerfdataWriter 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 "perfdata"
object PerfdataWriter "<%= @object_perfdatawritername %>" {
<%#- If any of the @ parameters are undefined, don't print anything for them: -%>
<%- if @host_perfdata_path -%>
host_perfdata_path = "<%= @host_perfdata_path %>"
<%- end -%>
<%- if @service_perfdata_path -%>
service_perfdata_path = "<%= @service_perfdata_path %>"
<%- end -%>
<%- if @host_temp_path -%>
host_temp_path = "<%= @host_temp_path %>"
<%- end -%>
<%- if @service_temp_path -%>
service_temp_path = "<%= @service_temp_path %>"
<%- end -%>
<%- if @host_format_template -%>
host_format_template = "<%= @host_format_template %>"
<%- end -%>
<%- if @service_format_template -%>
service_format_template = "<%= @service_format_template %>"
<%- end -%>
<%- if @rotation_interval -%>
rotation_interval = <%= @rotation_interval %>
<%- end -%>
}