Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

a individual service-object can't resolve custom host vars #1257

Closed
vita2 opened this issue Oct 23, 2017 · 6 comments
Closed

a individual service-object can't resolve custom host vars #1257

vita2 opened this issue Oct 23, 2017 · 6 comments
Assignees
Labels
Milestone

Comments

@vita2
Copy link
Contributor

vita2 commented Oct 23, 2017

hello tom,

i have created a service-object for a host and would like to fill up some fields with custom host vars. after the deployment i saw that the director doesn't recognizes the constants and puts the host variable into quotation marks.

Current Behavior

object Host "ds111" {
    import "generic-host"
    import "fields-snmp"
    ...

    ...
    vars.snmp_version = "3"
    vars.snmpv3_auth = "abc"
    ...
    vars.snmpv3_user = "xyz"
    ...
}
object Service "snmp_synology" {
    host_name = "ds111"
    import "snmp_synology"

    vars.snmp_synology_password = "$host.vars.snmpv3_auth$"
    vars.snmp_synology_username = "$host.vars.snmpv3_user$"
}

Your Environment

  • Director version (System - About): commit 567d972
  • Icinga Web 2 version and modules (System - About): 2.4.2
  • Icinga 2 version (icinga2 --version): r2.7.1-1
  • Operating System and version: Debian Jessie 8.9 (3.16.0-4-amd64)
  • Webserver, PHP versions: nginx 1.6.2-5 + php5-fpm 5.6.30
@Thomas-Gelf
Copy link
Contributor

Sorry, I'm unable to understand the issue?!

@vita2
Copy link
Contributor Author

vita2 commented Oct 23, 2017

regarding my above mentioned configuration the director renders the constants $host.vars.snmpv3_auth$ and $host.vars.snmpv3_user$ as string with quotation marks. it doesn't recognizes it as constants so the check-command will get empty strings.

this happens only at individual service-objects assigned to one host. constants in service-apply-rules and service-templates aren't affected.

@Thomas-Gelf
Copy link
Contributor

Got confused because of the naming. These are not constants but macros/custom variables in Icinga 2. And they should work as expected this way. Did you try it out?

@Thomas-Gelf
Copy link
Contributor

We discussed this elsewhere and have been able to track it down, thanks @vita2! Part of this is a caching issue when the same variable has before been used in a different context. Other part is Icinga 2 behaving differently in objects and apply rules, the host object is not always available as one might expect.

@Thomas-Gelf Thomas-Gelf self-assigned this Oct 24, 2017
@Thomas-Gelf Thomas-Gelf added this to the 1.4.2 milestone Oct 24, 2017
@vita2
Copy link
Contributor Author

vita2 commented Oct 24, 2017

thank you so much for helping me with this issue, tom 👍 🍻

@Thomas-Gelf
Copy link
Contributor

You're welcome, thank you for your troubleshooting time helping me to track it down.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants