2014-02-05 15:53:22 +01:00
|
|
|
## <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" {
|
2014-03-31 18:38:15 +02:00
|
|
|
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" {
|
2014-03-31 18:38:15 +02:00
|
|
|
import "generic-service"
|
|
|
|
check_command = "ping4"
|
2014-04-04 18:41:54 +02:00
|
|
|
assign where host.vars.address
|
2013-10-02 09:50:26 +02:00
|
|
|
}
|
|
|
|
|
2014-03-29 01:13:28 +01:00
|
|
|
apply Service "ping6" {
|
2014-03-31 18:38:15 +02:00
|
|
|
import "generic-service"
|
|
|
|
check_command = "ping6"
|
2014-04-04 18:41:54 +02:00
|
|
|
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.
|