Added generic icinga2::conf define @7273
Signed-off-by: Nick Chappell <nick@intronic.org> Merged in from: https://github.com/Icinga/puppet-icinga2/pull/12 Refs #7273: https://dev.icinga.org/issues/7273
This commit is contained in:
parent
fa1c6fccaf
commit
8f5a201bc1
2 changed files with 86 additions and 0 deletions
26
README.md
26
README.md
|
@ -389,6 +389,32 @@ icinga2::object::sysloglogger { 'syslog-warning':
|
||||||
|
|
||||||
See [SyslogLogger](http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2#objecttype-servicegroup) on [docs.icinga.org](http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2#objecttype-sysloglogger) for more info.
|
See [SyslogLogger](http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2#objecttype-servicegroup) on [docs.icinga.org](http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2#objecttype-sysloglogger) for more info.
|
||||||
|
|
||||||
|
####`icinga2::conf`
|
||||||
|
|
||||||
|
This defined type creates custom files in the icinga2/ conf.d directory.
|
||||||
|
|
||||||
|
The content of the file can be managed with two alternative parameters
|
||||||
|
|
||||||
|
`template` is erb tmplate to use for the content (ie: site/icinga2/baseservices.conf.erb)
|
||||||
|
`source` is the file server source url for a static file (ie: puppet:///modules/site/icinga2/baseservices.conf)
|
||||||
|
|
||||||
|
To dynamically manage the variables of your template use the parameter:
|
||||||
|
`options_hash` it can be feed by an hash of data that is accessible in the template (<%= @options_hash['groups'] %>
|
||||||
|
|
||||||
|
Example usage:
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
icinga2::conf { 'baseservices':
|
||||||
|
template => 'site/icinga2/baseservices.conf.erb',
|
||||||
|
options_hash => {
|
||||||
|
enable_notifications => true,
|
||||||
|
check_interval => '5',
|
||||||
|
groups => [ 'all-servers' , 'linux-servers' ],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
The latest documentation is also available on https://docs.icinga.org
|
The latest documentation is also available on https://docs.icinga.org
|
||||||
|
|
60
manifests/conf.pp
Normal file
60
manifests/conf.pp
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
# = Define: icinga2::conf
|
||||||
|
#
|
||||||
|
# General Apache define to be used to create generic custom .conf files
|
||||||
|
# Very simple wrapper to a normal file type
|
||||||
|
# Use source or template to define the source
|
||||||
|
#
|
||||||
|
# == Parameters
|
||||||
|
#
|
||||||
|
# [*source*]
|
||||||
|
# Sets the content of source parameter for the dotconf file
|
||||||
|
# If defined, icinga2 dotconf file will have the param: source => $source
|
||||||
|
#
|
||||||
|
# [*template*]
|
||||||
|
# Sets the path to the template to use as content for dotconf file
|
||||||
|
# If defined, icinga2 dotconf file has: content => content("$template")
|
||||||
|
# Note source and template parameters are mutually exclusive: don't use both
|
||||||
|
#
|
||||||
|
# [*options_hash*]
|
||||||
|
# Custom hash with key values to use in custom templates
|
||||||
|
#
|
||||||
|
define icinga2::conf (
|
||||||
|
$source = '' ,
|
||||||
|
$template = '' ,
|
||||||
|
$options_hash = undef,
|
||||||
|
$ensure = present,
|
||||||
|
$target_dir = '/etc/icinga2/conf.d',
|
||||||
|
$target_file_name = "${name}.conf",
|
||||||
|
$target_file_owner = 'root',
|
||||||
|
$target_file_group = 'root',
|
||||||
|
$target_file_mode = '644'
|
||||||
|
) {
|
||||||
|
|
||||||
|
validate_string($target_dir)
|
||||||
|
validate_string($target_file_name)
|
||||||
|
validate_string($target_file_owner)
|
||||||
|
validate_string($target_file_group)
|
||||||
|
validate_string($target_file_mode)
|
||||||
|
|
||||||
|
$manage_file_source = $source ? {
|
||||||
|
'' => undef,
|
||||||
|
default => $source,
|
||||||
|
}
|
||||||
|
|
||||||
|
$manage_file_content = $template ? {
|
||||||
|
'' => undef,
|
||||||
|
default => template($template),
|
||||||
|
}
|
||||||
|
|
||||||
|
file { "${target_dir}/${target_file_name}":
|
||||||
|
ensure => $ensure,
|
||||||
|
owner => $target_file_owner,
|
||||||
|
group => $target_file_group,
|
||||||
|
mode => $target_file_mode,
|
||||||
|
notify => Service['icinga2'],
|
||||||
|
source => $manage_file_source,
|
||||||
|
content => $manage_file_content,
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue