I looked through the docs, googled and played around and I can’t seem to get a host using resolved structure variables with key-value pairs to inherit a key-value pair from a template. I had it working with a simple, verbose key-value config, I am just wanting to use the resolved structures to make things a bit more sensible.
version: 2.13.2-1, Linux
templates.conf:
template Host “w-server” {
vars = {
w_critical = “600”
w_warning = “240”
w_instance = {
“Ours” = {
w_port = “1601”
}
}
}
}
hosts.conf:
object Host “w-pub” {
import “w-server”
vars += {
w_instance = {
“Theirs” = {
w_port = “1602”
}
“Mine” = {
w_port = “1603”
}
}
}
}
object list output
- vars
% = modified in ‘/etc/icinga2/zones.d/global/templates.conf’, lines 110:3-118:3
% = modified in ‘/etc/icinga2/zones.d/int/hosts.conf’, lines 9:3-18:3- w_critical = “600”
- w_instance
- Theirs
- w_port = “1602”
- Mine
- w_port = “1603”
- Theirs
- w_warning = “240”
I did play around with using additional += in the host config, but that didn’t do anything.
So there is no service generated for this host as defined in the template, the services showing in the object list and configured in the host are present and working. The template does work on other hosts that do not have additional key-value pairs of the same type in their config. Am I missing something, is this expected or is it a “feature” ?