Hi, it is solved.
Am 14.04.2015 um 01:15 schrieb Dustin Funk:
> Hi,
>
> i've a problem with resolving macros in dictionary definitions. I'll
> resolve $address$ in 'vars.dns["dns server"]' but the front-end shows
> $address$ instead the IP.
>
> Anybody knows if
>
> - my config is wrong
> - my macro call is wrong
> - the icinga2 parser doesn't resolve macros at this place
>
My opinion is that the parser can't resolve that.
>
> icinga-2.3.3:
>
> object Host "name" {
> import "generic-host"
> address = "111.222.333.444"
>
> vars.dns["dns server"] = {
> dns_lookup = "$address$"
> dns_server = "www.fem.tu-ilmenau.de"
> }
> }
>
> apply Service "dns" for (dns_name => config in host.vars.dns) {
> import "generic-service"
> vars += config
>
> display_name = dns_name
> check_command = "dns"
>
> assign where host.vars.dns
> }
>
The solution we evaluate is to move the variable/macro call in the appy
rule.
qpply Service "dns" for (dns_name => config in host.vars.dns) {
import "generic-service"
vars += config
display_name = dns_name
check_command = "dns"
if (vars.dns_lookup) {
vars.dns_lookup = vars.dns_lookup
} else {
vars.dns_lookup = host.address
}
if (vars.dns_server) {
vars.dns_server = vars.dns_server
} else {
vars.dns_server = host.address
}
assign where host.vars.dns
}
I think i can save a few lines when i negotiate the condition and delete
the duplicated vars-definitions.
Kindly regards,
nuts
signature.asc
Description: OpenPGP digital signature
_______________________________________________ icinga-users mailing list [email protected] https://lists.icinga.org/mailman/listinfo/icinga-users
