Merge branch 'develop'

Release version 0.6.1
This commit is contained in:
Nick Chappell 2014-12-02 21:41:13 -08:00
commit 2f375443ce
37 changed files with 1011 additions and 231 deletions

View file

@ -1,6 +1,13 @@
#Changelog
- - -
###v0.6.1 (December 2nd, 2014)
* Feature: [PR-54](https://github.com/Icinga/puppet-icinga2/pull/54) and [dev.icinga.org issue #7225](https://dev.icinga.org/issues/7225): Added a CompatLogger object defined type.
* Feature: [PR-55](https://github.com/Icinga/puppet-icinga2/pull/55) and [dev.icinga.org issue #7226](https://dev.icinga.org/issues/7226): Added a CheckResultReader object defined type.
* Feature: Added a parameter that controls whether to purge unmanaged files in `/etc/icinga2/objects/`
* Feature: [dev.icinga.org issue #7856](https://dev.icinga.org/issues/7856): Added a parameter to each object defined type that can controle whether the Icinga 2 service gets refreshed; it can be set to false if the module is being used to just generate object definition files and isn't managing the service
###v0.6.0 (November 19th, 2014)
* Added a defined type for `ServiceGroup` objects
@ -10,7 +17,7 @@
* Feature [#7264](https://dev.icinga.org/issues/7264): Added Debian 7 support
* Feature: Added the ability to use the Debmon repository on Debian 7 systems: [PR-17](https://github.com/Icinga/puppet-icinga2/pull/17)
* Feature: Added the ability to make NRPE accept command arguments; turned off by default for obvious security reasons: [PR-22](https://github.com/Icinga/puppet-icinga2/pull/22)
* Feature: Added the ability to enable/disable Icinga 2 components via parameters: [PR-23](https://github.com/Icinga/puppet-icinga2/pull/23)
* Feature: Added the ability to enable/disable Icinga 2 components via parameters: [PR-23](https://github.com/Icinga/puppet-icinga2/pull/23)
* Feature: Added a `GraphiteWriter` object defined type: [PR-24](https://github.com/Icinga/puppet-icinga2/pull/24)
* Feature: Added the ability to upload or create custom check plugins on an Icinga 2 server (as opposed to just for NRPE clients): [PR-27](https://github.com/Icinga/puppet-icinga2/pull/27)
* Bug [#7308](https://dev.icinga.org/issues/7308): Allow multiple `assign_where` and `ignore_where` conditions
@ -21,7 +28,6 @@
* Feature: [PR-35](https://github.com/Icinga/puppet-icinga2/pull/35): Added the ability to use a static file or custom ERB template for check command objects
* 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

View file

@ -300,6 +300,22 @@ icinga2::checkplugin { 'check_diskstats':
This module includes several defined types that can be used to automatically generate Icinga 2 format object definitions. They function in a similar way to [the built-in Nagios types that are included in Puppet](http://docs.puppetlabs.com/guides/exported_resources.html#exported-resources-with-nagios).
####Default object file locations, owner, group and mode
The default file location for each object type is controlled by the `target_file_dir` parameter. For each object type, it defaults to a subdirectory under `/etc/icinga2/objects`.
The default locations are under `/etc/icinga2/objects` and not `/etc/icinga2/conf.d/` so that user-defined objects can be kept completely separate from the objects included with Icinga 2. However, you can change the `target_file_dir` parameter to `/etc/icinga2/conf.d` if needed.
The default file owner and group are controlled by the `target_file_owner` and `target_file_group` parameters. Both default to `root`.
The default file mode is controlled by the `target_file_mode` parameter. It defaults to `0644`.
####Purging unmanaged object files
The `purge_unmanaged_object_files` parameter of the `icinga2::server` class controls whether object files in `/etc/icinga2/objects` that are not managed by Puppet get purged. It defaults to `false`.
**Note:** This will purge unmanaged subdirectories as well as unmanaged files!
####Exported resources
Like the built-in Nagios types, the Icinga 2 objects in this module can be exported to PuppetDB as virtual resources and collected on your Icinga 2 server.
@ -357,6 +373,21 @@ This means that they will not be added to the rendered object definition files.
**However**, this doesn't mean that the values are undefined in Icinga 2. Icinga 2 itself has built-in default values for many object parameters and falls back to them if one isn't present in an object definition. See the docs for individual object types in [Configuring Icinga 2](http://docs.icinga.org/icinga2/latest/doc/module/icinga2/toc#!/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2) for more info about which object parameters have what default values.
####Notifying the Icinga 2 service
By default, each object defined type will automatically notify and restart the Icinga 2 service. However, if you're using the module to just generate object files and not using it to manage the service, you'll likely get compilation errors about the `icinga2` service not being in the catalog.
Each object defined type has a boolean parameter, `refresh_icinga2_service`, that controls whether the object file will notify the service. To **not** notify the service, set it to `false`:
<pre>
icinga2::object::apply_dependency { 'usermail_dep_on_icinga2mail':
parent_host_name => 'icinga2mail.local',
target_file_owner => vagrant,
assign_where => 'match("^usermail*", host.name)',
refresh_icinga2_service => false,
}
</pre>
####[Objects](id:objects)
Object types:
@ -365,6 +396,8 @@ Object types:
* [icinga2::object::applynotificationtohost](#icinga2objectapplynotificationtohost)
* [icinga2::object::applynotificationtoservice](#icinga2objectapplynotificationtoservice)
* [icinga2::object::checkcommand](#icinga2objectcheckcommand)
* [icinga2::object::compatlogger](#icinga2objectcompatlogger)
* [icinga2::object::checkresultreader](#icinga2objectcheckresultreader)
* [icinga2::object::eventcommand](#icinga2objecteventcommand)
* [icinga2::object::externalcommandlistener](#icinga2objectexternalcommandlistener)
* [icinga2::object::host](#icinga2objecthost)
@ -506,6 +539,34 @@ Available parameters are:
* `target_file_group`
* `target_file_mode`
####`icinga2::object::compatlogger`
The `compatlogger` defined type can create `compatlogger` objects.
<pre>
icinga2::object::compatlogger { 'daily-log':
log_dir => '/var/log/icinga2/compat',
rotation_method => 'DAILY'
}
</pre>
Both patameters as optionals. The parameter `rotation_method` can one of `HOURLY`, `DAILY`, `WEEKLY` or `MONTHY`.
See [CompatLogger](http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2#objecttype-compatlogger) on [docs.icinga.org](http://docs.icinga.org/icinga2/latest/doc/module/icinga2/toc) for a full list of parameters.
####[`icinga2::object::checkresultreader`](id:object_checkresultreader)
The `checkresultreader` defined type can create `checkresultreader` objects.
Example:
<pre>
icinga2::object::checkresultreader {'reader':
spool_dir => '/data/check-results'
}
</pre>
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::eventcommand`
The `eventcommand` defined type can create `eventcommand` objects.

View file

@ -28,7 +28,9 @@ define icinga2::object::apply_dependency (
$target_file_ensure = file,
$target_file_owner = 'root',
$target_file_group = 'root',
$target_file_mode = '0644') {
$target_file_mode = '0644',
$refresh_icinga2_service = true
) {
# Do some validation of the class' parameters:
validate_string($object_name)
validate_string($display_name)
@ -46,16 +48,35 @@ define icinga2::object::apply_dependency (
validate_string($target_file_owner)
validate_string($target_file_group)
validate_string($target_file_mode)
validate_bool($refresh_icinga2_service)
validate_re($object_type, ['^Host', '^Service'])
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_apply_dependency.conf.erb'),
notify => Service['icinga2'],
#If the refresh_icinga2_service parameter is set to true...
if $refresh_icinga2_service == true {
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_apply_dependency.conf.erb'),
#...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file...
notify => Service['icinga2'],
}
}
#...otherwise, use the same file resource but without a notify => parameter:
else {
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_apply_dependency.conf.erb'),
}
}
}
}

View file

@ -29,7 +29,8 @@ define icinga2::object::apply_notification_to_host (
$target_file_ensure = file,
$target_file_owner = 'root',
$target_file_group = 'root',
$target_file_mode = '0644'
$target_file_mode = '0644',
$refresh_icinga2_service = true
) {
#Do some validation of the class' parameters:
@ -53,13 +54,33 @@ define icinga2::object::apply_notification_to_host (
validate_string($target_file_owner)
validate_string($target_file_group)
validate_re($target_file_mode, '^\d{4}$')
validate_bool($refresh_icinga2_service)
#If the refresh_icinga2_service parameter is set to true...
if $refresh_icinga2_service == true {
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_apply_notification_to_host.conf.erb'),
#...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file...
notify => Service['icinga2'],
}
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
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'],
}
#...otherwise, use the same file resource but without a notify => parameter:
else {
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_apply_notification_to_host.conf.erb'),
}
}
}

View file

@ -30,7 +30,8 @@ define icinga2::object::apply_notification_to_service (
$target_file_ensure = file,
$target_file_owner = 'root',
$target_file_group = 'root',
$target_file_mode = '0644'
$target_file_mode = '0644',
$refresh_icinga2_service = true
) {
#Do some validation of the class' parameters:
@ -55,13 +56,33 @@ define icinga2::object::apply_notification_to_service (
validate_string($target_file_owner)
validate_string($target_file_group)
validate_re($target_file_mode, '^\d{4}$')
validate_bool($refresh_icinga2_service)
#If the refresh_icinga2_service parameter is set to true...
if $refresh_icinga2_service == true {
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_apply_notification_to_service.conf.erb'),
#...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file...
notify => Service['icinga2'],
}
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
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'],
}
#...otherwise, use the same file resource but without a notify => parameter:
else {
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_apply_notification_to_service.conf.erb'),
}
}
}

View file

@ -2,7 +2,8 @@
#
# This is a defined type for Icinga 2 apply objects that apply services to hosts.
# See the following Icinga 2 doc page for more info:
# http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2#objecttype-service
# http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2#objecttype-host
# http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2#apply
#
# === Parameters
#
@ -42,7 +43,8 @@ define icinga2::object::apply_service_to_host (
$target_file_ensure = file,
$target_file_owner = 'root',
$target_file_group = 'root',
$target_file_mode = '0644'
$target_file_mode = '0644',
$refresh_icinga2_service = true
) {
#Do some validation of the class' parameters:
@ -55,15 +57,33 @@ define icinga2::object::apply_service_to_host (
validate_string($target_file_owner)
validate_string($target_file_group)
validate_string($target_file_mode)
validate_bool($refresh_icinga2_service)
#If the refresh_icinga2_service parameter is set to true...
if $refresh_icinga2_service == true {
file {"${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_apply_service_to_host.conf.erb'),
notify => Service['icinga2'],
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_apply_service_to_host.conf.erb'),
#...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file...
notify => Service['icinga2'],
}
}
#...otherwise, use the same file resource but without a notify => parameter:
else {
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_apply_service_to_host.conf.erb'),
}
}
}

View file

@ -29,6 +29,7 @@ define icinga2::object::checkcommand (
$target_file_owner = 'root',
$target_file_group = 'root',
$target_file_mode = '0644',
$refresh_icinga2_service = true
) {
#Do some validation of the class' parameters:
@ -50,31 +51,65 @@ define icinga2::object::checkcommand (
validate_string($target_file_owner)
validate_string($target_file_group)
validate_re($target_file_mode, '^\d{4}$')
validate_bool($refresh_icinga2_service)
if $checkcommand_file_distribution_method == 'content' {
file {"${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template("${checkcommand_template_module}/${checkcommand_template}"),
notify => Service['icinga2'],
}
}
elsif $checkcommand_file_distribution_method == 'source' {
file {"${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
source => $checkcommand_source_file,
notify => Service['icinga2'],
#If the refresh_icinga2_service parameter is set to true...
if $refresh_icinga2_service == true {
if $checkcommand_file_distribution_method == 'content' {
file {"${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template("${checkcommand_template_module}/${checkcommand_template}"),
notify => Service['icinga2'],
}
}
elsif $checkcommand_file_distribution_method == 'source' {
file {"${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
source => $checkcommand_source_file,
notify => Service['icinga2'],
}
}
else {
notify {'Missing/Incorrect File Distribution Method':
message => 'The parameter checkcommand_file_distribution_method is missing or incorrect. Please set content or source',
}
}
}
#...otherwise, use the same file resource but without a notify => parameter:
else {
notify {'Missing/Incorrect File Distribution Method':
message => 'The parameter checkcommand_file_distribution_method is missing or incorrect. Please set content or source',
if $checkcommand_file_distribution_method == 'content' {
file {"${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template("${checkcommand_template_module}/${checkcommand_template}"),
}
}
elsif $checkcommand_file_distribution_method == 'source' {
file {"${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
source => $checkcommand_source_file,
}
}
else {
notify {'Missing/Incorrect File Distribution Method':
message => 'The parameter checkcommand_file_distribution_method is missing or incorrect. Please set content or source',
}
}
}
}

View file

@ -0,0 +1,66 @@
# == Defined type: icinga2::object::checkresultreader
#
# This is a defined type for Icinga 2 apply objects that create Check Result Reader
# See the following Icinga 2 doc page for more info:
# http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2#objecttype-checkresultreader
#
# === Parameters
#
# See the inline comments.
#
define icinga2::object::checkresultreader (
$ensure = 'file',
$object_checkresultreadername = $name,
$spool_dir = undef,
$target_dir = '/etc/icinga2/objects/checkresultreaders',
$target_file_name = "${name}.conf",
$target_file_ensure = file,
$target_file_owner = 'root',
$target_file_group = 'root',
$target_file_mode = '0644',
$refresh_icinga2_service = true
) {
#Do some validation of the class' parameters:
if $object_checkresultreadername {
validate_string($object_checkresultreadername)
}
if $spool_dir {
validate_string($spool_dir)
}
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}$')
validate_bool($refresh_icinga2_service)
#If the refresh_icinga2_service parameter is set to true...
if $refresh_icinga2_service == true {
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_checkresultreader.conf.erb'),
#...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file...
notify => Service['icinga2'],
}
}
#...otherwise, use the same file resource but without a notify => parameter:
else {
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_checkresultreader.conf.erb'),
}
}
}

View file

@ -0,0 +1,70 @@
# == Defined type: icinga2::object::compatlogger
#
# This is a defined type for Icinga 2 apply objects that create Compat Logger
# See the following Icinga 2 doc page for more info:
# http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2#objecttype-compatlogger
#
# === Parameters
#
# See the inline comments.
#
define icinga2::object::compatlogger (
$ensure = 'file',
$object_compatloggername = $name,
$log_dir = undef,
$rotation_method = undef,
$target_dir = '/etc/icinga2/objects/compatloggers',
$target_file_name = "${name}.conf",
$target_file_ensure = file,
$target_file_owner = 'root',
$target_file_group = 'root',
$target_file_mode = '0644',
$refresh_icinga2_service = true
) {
#Do some validation of the class' parameters:
if $object_compatloggername {
validate_string($object_compatloggername)
}
if $log_dir {
validate_string($log_dir)
}
if $rotation_method {
validate_string($rotation_method)
}
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}$')
validate_bool($refresh_icinga2_service)
#If the refresh_icinga2_service parameter is set to true...
if $refresh_icinga2_service == true {
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_compatlogger.conf.erb'),
#...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file...
notify => Service['icinga2'],
}
}
#...otherwise, use the same file resource but without a notify => parameter:
else {
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_compatlogger.conf.erb'),
}
}
}

View file

@ -25,7 +25,9 @@ define icinga2::object::dependency (
$target_file_ensure = file,
$target_file_owner = 'root',
$target_file_group = 'root',
$target_file_mode = '0644') {
$target_file_mode = '0644',
$refresh_icinga2_service = true
) {
# Do some validation of the class' parameters:
validate_string($object_name)
validate_string($display_name)
@ -43,14 +45,33 @@ define icinga2::object::dependency (
validate_string($target_file_owner)
validate_string($target_file_group)
validate_string($target_file_mode)
validate_bool($refresh_icinga2_service)
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_dependency.conf.erb'),
notify => Service['icinga2'],
#If the refresh_icinga2_service parameter is set to true...
if $refresh_icinga2_service == true {
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_dependency.conf.erb'),
#...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file...
notify => Service['icinga2'],
}
}
#...otherwise, use the same file resource but without a notify => parameter:
else {
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_dependency.conf.erb'),
}
}
}

View file

@ -24,7 +24,8 @@ define icinga2::object::eventcommand (
$target_file_ensure = file,
$target_file_owner = 'root',
$target_file_group = 'root',
$target_file_mode = '0644'
$target_file_mode = '0644',
$refresh_icinga2_service = true
) {
#Do some validation of the class' parameters:
@ -43,15 +44,33 @@ define icinga2::object::eventcommand (
validate_string($target_file_owner)
validate_string($target_file_group)
validate_re($target_file_mode, '^\d{4}$')
validate_bool($refresh_icinga2_service)
#If the refresh_icinga2_service parameter is set to true...
if $refresh_icinga2_service == true {
file {"${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_eventcommand.conf.erb'),
notify => Service['icinga2'],
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_eventcommand.conf.erb'),
#...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file...
notify => Service['icinga2'],
}
}
#...otherwise, use the same file resource but without a notify => parameter:
else {
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_eventcommand.conf.erb'),
}
}
}

View file

@ -18,7 +18,8 @@ define icinga2::object::externalcommandlistener (
$target_file_ensure = file,
$target_file_owner = 'root',
$target_file_group = 'root',
$target_file_mode = '0644'
$target_file_mode = '0644',
$refresh_icinga2_service = true
) {
#Do some validation of the class' parameters:
@ -33,15 +34,33 @@ define icinga2::object::externalcommandlistener (
validate_string($target_file_owner)
validate_string($target_file_group)
validate_re($target_file_mode, '^\d{4}$')
validate_bool($refresh_icinga2_service)
#If the refresh_icinga2_service parameter is set to true...
if $refresh_icinga2_service == true {
file {"${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_externalcommandlistener.conf.erb'),
notify => Service['icinga2'],
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_externalcommandlistener.conf.erb'),
#...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file...
notify => Service['icinga2'],
}
}
#...otherwise, use the same file resource but without a notify => parameter:
else {
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_externalcommandlistener.conf.erb'),
}
}
}

View file

@ -19,18 +19,39 @@ define icinga2::object::graphitewriter (
$target_file_ensure = file,
$target_file_owner = 'root',
$target_file_group = 'root',
$target_file_mode = '0644'
$target_file_mode = '0644',
$refresh_icinga2_service = true
) {
#Do some validation
validate_string($host)
validate_bool($refresh_icinga2_service)
#If the refresh_icinga2_service parameter is set to true...
if $refresh_icinga2_service == true {
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_graphitewriter.conf.erb'),
#...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file...
notify => Service['icinga2'],
}
file {"${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_graphitewriter.conf.erb'),
notify => Service['icinga2'],
}
#...otherwise, use the same file resource but without a notify => parameter:
else {
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_graphitewriter.conf.erb'),
}
}
}

View file

@ -37,12 +37,13 @@ define icinga2::object::host (
$action_url = undef,
$icon_image = undef,
$icon_image_alt = undef,
$target_dir = '/etc/icinga2/conf.d',
$target_dir = '/etc/icinga2/objects',
$target_file_name = "${fqdn}.conf",
$target_file_ensure = file,
$target_file_owner = 'root',
$target_file_group = 'root',
$target_file_mode = '0644'
$target_file_mode = '0644',
$refresh_icinga2_service = true
) {
#Do some validation of the class' parameters:
@ -57,14 +58,33 @@ define icinga2::object::host (
validate_string($target_file_owner)
validate_string($target_file_group)
validate_string($target_file_mode)
validate_bool($refresh_icinga2_service)
file {"${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_host.conf.erb'),
notify => Service['icinga2'],
#If the refresh_icinga2_service parameter is set to true...
if $refresh_icinga2_service == true {
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_host.conf.erb'),
#...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file...
notify => Service['icinga2'],
}
}
#...otherwise, use the same file resource but without a notify => parameter:
else {
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_host.conf.erb'),
}
}
}

View file

@ -14,14 +14,15 @@ define icinga2::object::hostgroup (
$display_name = $name,
$template_to_import = undef,
$groups = [],
$target_dir = '/etc/icinga2/conf.d',
$target_dir = '/etc/icinga2/objects',
$target_file_name = "${name}.conf",
$target_file_ensure = file,
$target_file_owner = 'root',
$target_file_group = 'root',
$target_file_mode = '0644',
$assign_where = undef,
$ignore_where = undef
$ignore_where = undef,
$refresh_icinga2_service = true
) {
#Do some validation of the class' parameters:
@ -34,14 +35,33 @@ define icinga2::object::hostgroup (
validate_string($target_file_owner)
validate_string($target_file_group)
validate_string($target_file_mode)
validate_bool($refresh_icinga2_service)
file {"${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_hostgroup.conf.erb'),
notify => Service['icinga2'],
#If the refresh_icinga2_service parameter is set to true...
if $refresh_icinga2_service == true {
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_hostgroup.conf.erb'),
#...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file...
notify => Service['icinga2'],
}
}
#...otherwise, use the same file resource but without a notify => parameter:
else {
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_hostgroup.conf.erb'),
}
}
}

View file

@ -42,7 +42,8 @@ define icinga2::object::idomysqlconnection (
$target_file_name = "${name}.conf",
$target_file_owner = 'root',
$target_file_group = 'root',
$target_file_mode = '0644'
$target_file_mode = '0644',
$refresh_icinga2_service = true
) {
#Do some validation of the class' parameters:
@ -61,14 +62,33 @@ define icinga2::object::idomysqlconnection (
validate_string($target_file_owner)
validate_string($target_file_group)
validate_string($target_file_mode)
validate_bool($refresh_icinga2_service)
file {"${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_idomysqlconnection.conf.erb'),
notify => Service['icinga2'],
#If the refresh_icinga2_service parameter is set to true...
if $refresh_icinga2_service == true {
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_idomysqlconnection.conf.erb'),
#...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file...
notify => Service['icinga2'],
}
}
#...otherwise, use the same file resource but without a notify => parameter:
else {
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_idomysqlconnection.conf.erb'),
}
}
}

View file

@ -42,7 +42,8 @@ define icinga2::object::idopgsqlconnection (
$target_file_ensure = file,
$target_file_owner = 'root',
$target_file_group = 'root',
$target_file_mode = '0644'
$target_file_mode = '0644',
$refresh_icinga2_service = true
) {
#Do some validation of the class' parameters:
@ -61,14 +62,33 @@ define icinga2::object::idopgsqlconnection (
validate_string($target_file_owner)
validate_string($target_file_group)
validate_string($target_file_mode)
validate_bool($refresh_icinga2_service)
file {"${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_idopgsqlconnection.conf.erb'),
notify => Service['icinga2'],
#If the refresh_icinga2_service parameter is set to true...
if $refresh_icinga2_service == true {
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_idopgsqlconnection.conf.erb'),
#...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file...
notify => Service['icinga2'],
}
}
#...otherwise, use the same file resource but without a notify => parameter:
else {
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_idopgsqlconnection.conf.erb'),
}
}
}

View file

@ -10,7 +10,7 @@
#
define icinga2::object::livestatuslistener (
$object_livestatuslistenername = $name,
$object_livestatuslistenername = $name,
$socket_type = undef,
$bind_host = undef,
$bind_port = undef,
@ -21,7 +21,8 @@ define icinga2::object::livestatuslistener (
$target_file_ensure = file,
$target_file_owner = 'root',
$target_file_group = 'root',
$target_file_mode = '0644'
$target_file_mode = '0644',
$refresh_icinga2_service = true
) {
#Do some validation of the class' parameters:
@ -48,15 +49,33 @@ define icinga2::object::livestatuslistener (
validate_string($target_file_owner)
validate_string($target_file_group)
validate_re($target_file_mode, '^\d{4}$')
validate_bool($refresh_icinga2_service)
#If the refresh_icinga2_service parameter is set to true...
if $refresh_icinga2_service == true {
file {"${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_livestatuslistener.conf.erb'),
notify => Service['icinga2'],
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_livestatuslistener.conf.erb'),
#...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file...
notify => Service['icinga2'],
}
}
#...otherwise, use the same file resource but without a notify => parameter:
else {
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_livestatuslistener.conf.erb'),
}
}
}

View file

@ -27,7 +27,8 @@ define icinga2::object::notification (
$target_file_ensure = file,
$target_file_owner = 'root',
$target_file_group = 'root',
$target_file_mode = '0644'
$target_file_mode = '0644',
$refresh_icinga2_service = true
) {
#Do some validation of the class' parameters:
@ -66,15 +67,33 @@ define icinga2::object::notification (
validate_string($target_file_owner)
validate_string($target_file_group)
validate_re($target_file_mode, '^\d{4}$')
validate_bool($refresh_icinga2_service)
#If the refresh_icinga2_service parameter is set to true...
if $refresh_icinga2_service == true {
file {"${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_notification.conf.erb'),
notify => Service['icinga2'],
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_notification.conf.erb'),
#...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file...
notify => Service['icinga2'],
}
}
#...otherwise, use the same file resource but without a notify => parameter:
else {
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_notification.conf.erb'),
}
}
}

View file

@ -24,7 +24,8 @@ define icinga2::object::notificationcommand (
$target_file_ensure = file,
$target_file_owner = 'root',
$target_file_group = 'root',
$target_file_mode = '0644'
$target_file_mode = '0644',
$refresh_icinga2_service = true
) {
#Do some validation of the class' parameters:
@ -43,15 +44,33 @@ define icinga2::object::notificationcommand (
validate_string($target_file_owner)
validate_string($target_file_group)
validate_re($target_file_mode, '^\d{4}$')
validate_bool($refresh_icinga2_service)
#If the refresh_icinga2_service parameter is set to true...
if $refresh_icinga2_service == true {
file {"${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_notificationcommand.conf.erb'),
notify => Service['icinga2'],
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_notificationcommand.conf.erb'),
#...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file...
notify => Service['icinga2'],
}
}
#...otherwise, use the same file resource but without a notify => parameter:
else {
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_notificationcommand.conf.erb'),
}
}
}

View file

@ -24,7 +24,8 @@ define icinga2::object::perfdatawriter (
$target_file_ensure = file,
$target_file_owner = 'root',
$target_file_group = 'root',
$target_file_mode = '0644'
$target_file_mode = '0644',
$refresh_icinga2_service = true
) {
#Do some validation of the class' parameters:
@ -57,15 +58,33 @@ define icinga2::object::perfdatawriter (
validate_string($target_file_owner)
validate_string($target_file_group)
validate_re($target_file_mode, '^\d{4}$')
validate_bool($refresh_icinga2_service)
#If the refresh_icinga2_service parameter is set to true...
if $refresh_icinga2_service == true {
file {"${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_perfdatawriter.conf.erb'),
notify => Service['icinga2'],
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_perfdatawriter.conf.erb'),
#...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file...
notify => Service['icinga2'],
}
}
#...otherwise, use the same file resource but without a notify => parameter:
else {
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_perfdatawriter.conf.erb'),
}
}
}

View file

@ -23,7 +23,8 @@ define icinga2::object::scheduleddowntime (
$target_file_ensure = file,
$target_file_owner = 'root',
$target_file_group = 'root',
$target_file_mode = '0644'
$target_file_mode = '0644',
$refresh_icinga2_service = true
) {
#Do some validation of the define's parameters:
@ -42,14 +43,33 @@ define icinga2::object::scheduleddowntime (
validate_string($target_file_owner)
validate_string($target_file_group)
validate_string($target_file_mode)
validate_bool($refresh_icinga2_service)
file {"${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_scheduleddowntime.conf.erb'),
notify => Service['icinga2'],
#If the refresh_icinga2_service parameter is set to true...
if $refresh_icinga2_service == true {
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_scheduleddowntime.conf.erb'),
#...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file...
notify => Service['icinga2'],
}
}
#...otherwise, use the same file resource but without a notify => parameter:
else {
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_scheduleddowntime.conf.erb'),
}
}
}

View file

@ -41,7 +41,8 @@ define icinga2::object::service (
$target_file_ensure = file,
$target_file_owner = 'root',
$target_file_group = 'root',
$target_file_mode = '0644'
$target_file_mode = '0644',
$refresh_icinga2_service = true
) {
#Do some validation of the class' parameters:
@ -56,14 +57,33 @@ define icinga2::object::service (
validate_string($target_file_owner)
validate_string($target_file_group)
validate_string($target_file_mode)
validate_bool($refresh_icinga2_service)
file {"${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_service.conf.erb'),
notify => Service['icinga2'],
#If the refresh_icinga2_service parameter is set to true...
if $refresh_icinga2_service == true {
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_service.conf.erb'),
#...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file...
notify => Service['icinga2'],
}
}
#...otherwise, use the same file resource but without a notify => parameter:
else {
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_service.conf.erb'),
}
}
}

View file

@ -14,14 +14,15 @@ define icinga2::object::servicegroup (
$display_name = $name,
$template_to_import = undef,
$groups = [],
$target_dir = '/etc/icinga2/conf.d',
$target_dir = '/etc/icinga2/objects',
$target_file_name = "${name}.conf",
$target_file_ensure = file,
$target_file_owner = 'root',
$target_file_group = 'root',
$target_file_mode = '0644',
$assign_where = undef,
$ignore_where = undef
$ignore_where = undef,
$refresh_icinga2_service = true
) {
#Do some validation of the class' parameters:
@ -34,14 +35,33 @@ define icinga2::object::servicegroup (
validate_string($target_file_owner)
validate_string($target_file_group)
validate_string($target_file_mode)
validate_bool($refresh_icinga2_service)
file {"${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_servicegroup.conf.erb'),
notify => Service['icinga2'],
#If the refresh_icinga2_service parameter is set to true...
if $refresh_icinga2_service == true {
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_servicegroup.conf.erb'),
#...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file...
notify => Service['icinga2'],
}
}
#...otherwise, use the same file resource but without a notify => parameter:
else {
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_servicegroup.conf.erb'),
}
}
}

View file

@ -19,7 +19,8 @@ define icinga2::object::statusdatawriter (
$target_file_ensure = file,
$target_file_owner = 'root',
$target_file_group = 'root',
$target_file_mode = '0644'
$target_file_mode = '0644',
$refresh_icinga2_service = true
) {
#Do some validation of the class' parameters:
@ -40,15 +41,33 @@ define icinga2::object::statusdatawriter (
validate_string($target_file_owner)
validate_string($target_file_group)
validate_re($target_file_mode, '^\d{4}$')
validate_bool($refresh_icinga2_service)
#If the refresh_icinga2_service parameter is set to true...
if $refresh_icinga2_service == true {
file {"${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_statusdatawriter.conf.erb'),
notify => Service['icinga2'],
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_statusdatawriter.conf.erb'),
#...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file...
notify => Service['icinga2'],
}
}
#...otherwise, use the same file resource but without a notify => parameter:
else {
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_statusdatawriter.conf.erb'),
}
}
}

View file

@ -12,12 +12,13 @@
define icinga2::object::sysloglogger (
$object_name = $name,
$severity = 'warning',
$target_dir = '/etc/icinga2/conf.d',
$target_dir = '/etc/icinga2/objects',
$target_file_name = "${name}.conf",
$target_file_ensure = file,
$target_file_owner = 'root',
$target_file_group = 'root',
$target_file_mode = '0644'
$target_file_mode = '0644',
$refresh_icinga2_service = true
) {
#Do some validation of the class' parameters:
@ -28,14 +29,33 @@ define icinga2::object::sysloglogger (
validate_string($target_file_owner)
validate_string($target_file_group)
validate_string($target_file_mode)
validate_bool($refresh_icinga2_service)
file {"${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_sysloglogger.conf.erb'),
notify => Service['icinga2'],
#If the refresh_icinga2_service parameter is set to true...
if $refresh_icinga2_service == true {
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_sysloglogger.conf.erb'),
#...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file...
notify => Service['icinga2'],
}
}
#...otherwise, use the same file resource but without a notify => parameter:
else {
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_sysloglogger.conf.erb'),
}
}
}

View file

@ -2,7 +2,7 @@
#
# This is a defined type for Icinga 2 host objects.
# See the following Icinga 2 doc page for more info:
# http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/monitoring-basics#timeperiods
# http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2#objecttype-timeperiod
#
# === Parameters
#
@ -15,12 +15,13 @@ define icinga2::object::timeperiod (
$timeperiod_display_name = undef,
$methods = undef,
$ranges = {},
$timeperiod_target_dir = '/etc/icinga2/objects/timeperiods',
$timeperiod_target_file_name = "${name}.conf",
$target_dir = '/etc/icinga2/objects/timeperiods',
$target_file_name = "${name}.conf",
$target_file_ensure = file,
$target_file_owner = 'root',
$target_file_group = 'root',
$target_file_mode = '0644',
$refresh_icinga2_service = true
) {
# Do some validation of the class' parameters:
@ -36,13 +37,33 @@ define icinga2::object::timeperiod (
validate_string($target_file_owner)
validate_string($target_file_group)
validate_re($target_file_mode, '^\d{4}$')
validate_bool($refresh_icinga2_service)
#If the refresh_icinga2_service parameter is set to true...
if $refresh_icinga2_service == true {
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_timeperiod.conf.erb'),
#...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file...
notify => Service['icinga2'],
}
file {"${timeperiod_target_dir}/${timeperiod_target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_timeperiod.conf.erb'),
notify => Service['icinga2'],
}
#...otherwise, use the same file resource but without a notify => parameter:
else {
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_timeperiod.conf.erb'),
}
}
}

View file

@ -20,12 +20,13 @@ define icinga2::object::user (
$period = undef,
$types = [],
$states = [],
$target_dir = '/etc/icinga2/conf.d',
$target_dir = '/etc/icinga2/objects',
$target_file_name = "${name}.conf",
$target_file_ensure = file,
$target_file_owner = 'root',
$target_file_group = 'root',
$target_file_mode = '0644'
$target_file_mode = '0644',
$refresh_icinga2_service = true
) {
#Do some validation of the class' parameters:
@ -41,14 +42,33 @@ define icinga2::object::user (
validate_string($target_file_owner)
validate_string($target_file_group)
validate_string($target_file_mode)
validate_bool($refresh_icinga2_service)
file {"${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_user.conf.erb'),
notify => Service['icinga2'],
#If the refresh_icinga2_service parameter is set to true...
if $refresh_icinga2_service == true {
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_user.conf.erb'),
#...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file...
notify => Service['icinga2'],
}
}
#...otherwise, use the same file resource but without a notify => parameter:
else {
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_user.conf.erb'),
}
}
}

View file

@ -14,14 +14,15 @@ define icinga2::object::usergroup (
$display_name = $name,
$template_to_import = undef,
$groups = [],
$target_dir = '/etc/icinga2/conf.d',
$target_dir = '/etc/icinga2/objects',
$target_file_name = "${name}.conf",
$target_file_ensure = file,
$target_file_owner = 'root',
$target_file_group = 'root',
$target_file_mode = '0644',
$assign_where = undef,
$ignore_where = undef
$ignore_where = undef,
$refresh_icinga2_service = true
) {
#Do some validation of the class' parameters:
@ -33,14 +34,33 @@ define icinga2::object::usergroup (
validate_string($target_file_owner)
validate_string($target_file_group)
validate_string($target_file_mode)
validate_bool($refresh_icinga2_service)
file {"${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_usergroup.conf.erb'),
notify => Service['icinga2'],
#If the refresh_icinga2_service parameter is set to true...
if $refresh_icinga2_service == true {
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_usergroup.conf.erb'),
#...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file...
notify => Service['icinga2'],
}
}
#...otherwise, use the same file resource but without a notify => parameter:
else {
file { "${target_dir}/${target_file_name}":
ensure => $target_file_ensure,
owner => $target_file_owner,
group => $target_file_group,
mode => $target_file_mode,
content => template('icinga2/object_usergroup.conf.erb'),
}
}
}

View file

@ -235,6 +235,9 @@ class icinga2::params {
#Fail if we're on any other OS:
default: { fail("${::operatingsystem} is not supported!") }
}
#Whether to purge object files or directories in /etc/icinga2/objects that aren't managed by Puppet
$purge_unmanaged_object_files = false
##################
# Icinga 2 server service settings

View file

@ -26,6 +26,7 @@ class icinga2::server (
$install_mail_utils_package = $icinga2::params::install_mail_utils_package,
$server_enabled_features = $icinga2::params::server_enabled_features,
$server_disabled_features = $icinga2::params::server_disabled_features,
$purge_unmanaged_object_files = $icinga2::params::purge_unmanaged_object_files
) inherits icinga2::params {
#Do some validation of parameters so we know we have the right data types:

View file

@ -15,6 +15,18 @@ class icinga2::server::config inherits icinga2::server {
include icinga2::params
if $purge_unmanaged_object_files == true {
$recurse_objects = true
$purge_objects = true
$force_purge = true
}
else {
$recurse_objects = false
$purge_objects = false
$force_purge = true
}
#Directory resource for /etc/icinga2/:
file { '/etc/icinga2/':
ensure => directory,
@ -99,6 +111,9 @@ class icinga2::server::config inherits icinga2::server {
owner => $etc_icinga2_obejcts_owner,
group => $etc_icinga2_obejcts_group,
mode => $etc_icinga2_obejcts_mode,
recurse => $recurse_objects,
purge => $purge_objects,
force => $force_purge
}
#Directory resource for /etc/icinga2/objects/hosts/:

View file

@ -1,9 +1,9 @@
# Disable Icinga 2 Features/Modules
define icinga2::server::features::disable () {
exec { "icinga2-disable-feature ${name}":
exec { "icinga2 disable feature ${name}":
user => 'root',
path => '/usr/bin:/usr/sbin:/bin/:/sbin',
command => "/usr/sbin/icinga2-disable-feature ${name}",
command => "/usr/sbin/icinga2 feature disable ${name}",
unless => "[ ! -f /etc/icinga2/features-enabled/${name}.conf ]",
require => Class['icinga2::server::install::packages'],
}

View file

@ -1,9 +1,9 @@
# Enable Icinga 2 Features/Modules
define icinga2::server::features::enable () {
exec { "icinga2-enable-feature ${name}":
exec { "icinga2 enable feature ${name}":
user => 'root',
path => '/usr/bin:/usr/sbin:/bin/:/sbin',
command => "/usr/sbin/icinga2-enable-feature ${name}",
command => "/usr/sbin/icinga2 feature enable ${name}",
unless => "[ ! -f /etc/icinga2/features-available/${name}.conf ] || [ -f /etc/icinga2/features-enabled/${name}.conf ]",
require => Class['icinga2::server::install::packages'],
}

View file

@ -149,7 +149,7 @@ class icinga2::server::install::execs inherits icinga2::server {
exec { 'mysql_module_enable':
user => 'root',
path => '/usr/bin:/usr/sbin:/bin/:/sbin',
command => '/usr/sbin/icinga2-enable-feature ido-mysql && touch /etc/icinga2/mysql_module_loaded.txt',
command => '/usr/sbin/icinga2 enable feature ido-mysql && touch /etc/icinga2/mysql_module_loaded.txt',
creates => '/etc/icinga2/mysql_module_loaded.txt',
require => Exec['mysql_schema_load'],
}
@ -168,7 +168,7 @@ class icinga2::server::install::execs inherits icinga2::server {
exec { 'postgres_module_enable':
user => 'root',
path => '/usr/bin:/usr/sbin:/bin/:/sbin',
command => '/usr/sbin/icinga2-enable-feature ido-pgsql && touch /etc/icinga2/postgres_module_loaded.txt',
command => '/usr/sbin/icinga2 enable feature ido-pgsql && touch /etc/icinga2/postgres_module_loaded.txt',
creates => '/etc/icinga2/postgres_module_loaded.txt',
require => Exec['postgres_schema_load'],
}

View file

@ -0,0 +1,20 @@
/**
* WARNING: This CheckResultReader definition is automatically generated by Puppet.
* ANY MANUAL CHANGES TO IT WILL GET OVERWRITTEN!
*/
/**
* A CheckResultReader 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 "compat"
object CheckResultReader "<%= @object_checkresultreadername %>" {
<%#- If any of the @ parameters are undefined, don't print anything for them: -%>
<%- if @spool_dir -%>
spool_dir = "<%= @spool_dir %>"
<%- end -%>
}

View file

@ -0,0 +1,24 @@
/**
* WARNING: This CompatLogger definition is automatically generated by Puppet.
* ANY MANUAL CHANGES TO IT WILL GET OVERWRITTEN!
*/
/**
* A CompatLogger 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 "compat"
object CompatLogger "<%= @object_compatloggername %>" {
<%#- If any of the @ parameters are undefined, don't print anything for them: -%>
<%- if @log_dir -%>
log_dir = "<%= @log_dir %>"
<%- end -%>
<%- if @rotation_method -%>
rotation_method = "<%= @rotation_method %>"
<%- end -%>
}