-
Notifications
You must be signed in to change notification settings - Fork 43
Open
Labels
featureNew feature or requestNew feature or request
Description
Hi all
I want to create a Service which imports a Service Template. We have four different Service Templates, depending on the priority. My idea was to add a variable to the host and then import the specified service template.
Here's an example Host object:
object Host "host.example.com" {
import "priority1-host"
address = "192.168.1.10"
vars.nb["monitoring_icinga"] = true
vars.nb["tenant"] = "UMBRELLA"
vars.nb["config"] = {
checks = [ "check_service_123", ]
}
vars.nb["priority"] = "priority1"
vars.nb["platform"] = "Ubuntu-22-04"
vars.nb["service_priority"] = "priority1-service"
}
And here's the Service object that I want to create:
- name: CPU
type: Service
file: zones.d/main/services/services.conf
apply: true
imports:
- host.vars.nb.service_priority
check_command: check_load
command_endpoint: host.name
assign:
- linux-hosts in host.groups
vars:
notification: true
The problem is that the icinga2_object.py script adds the import as string, not as variable. So the rendered config looks like this:
apply Service "CPU" {
import "host.vars.nb.service_priority"
check_command = "check_load"
command_endpoint = host.name
assign where "linux-hosts" in host.groups
vars.notification = true
}
But it should look like this (import without quotes):
apply Service "CPU" {
import host.vars.nb.service_priority
check_command = "check_load"
command_endpoint = host.name
assign where "linux-hosts" in host.groups
vars.notification = true
}
I'm not quite sure how this can be solved. Because sometimes the import should be a string, e.g. if I import priority1-service directly, but if it's a variable, it should be without quotes...
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
featureNew feature or requestNew feature or request