icinga2/doc/3.05-using-templates.md

35 lines
1006 B
Markdown
Raw Normal View History

## <a id="using-templates"></a> Using Templates
2013-10-02 09:50:26 +02:00
Templates may be used to apply a set of similar settings to more than one
object.
2013-10-07 09:35:44 +02:00
For example, rather than manually creating a `ping` service object for each of
2013-10-02 09:50:26 +02:00
your hosts you can use templates to avoid having to copy & paste parts of your
2013-10-10 16:55:59 +02:00
configuration:
2013-10-02 09:50:26 +02:00
2014-03-29 01:13:28 +01:00
template Service "generic-service" {
max_check_attempts = 3
check_interval = 5m
retry_interval = 1m
2014-03-29 01:13:28 +01:00
enable_perfdata = true
2013-10-02 09:50:26 +02:00
}
2014-03-29 01:13:28 +01:00
apply Service "ping4" {
import "generic-service"
check_command = "ping4"
assign where host.vars.address
2013-10-02 09:50:26 +02:00
}
2014-03-29 01:13:28 +01:00
apply Service "ping6" {
import "generic-service"
check_command = "ping6"
assign where host.vars.address6
2013-10-02 09:50:26 +02:00
}
2014-03-29 01:13:28 +01:00
In this example both `ping4` and `ping6` services inherit properties from the
template `generic-service`.
2013-10-02 09:50:26 +02:00
2014-03-29 01:13:28 +01:00
Objects as well as templates themselves can import an arbitrary number of
2013-10-02 09:50:26 +02:00
templates. Attributes inherited from a template can be overridden in the
object if necessary.