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

Bug when using value or key variable #344

Open
lucagubler opened this issue Nov 11, 2024 · 0 comments · May be fixed by #346
Open

Bug when using value or key variable #344

lucagubler opened this issue Nov 11, 2024 · 0 comments · May be fixed by #346

Comments

@lucagubler
Copy link
Contributor

There's a bug when using the value or key variable in combination with apply_for loops. I want to loop over a dictionary or list and then use the key or value to access items.

Here's an example service

...
  - name: Check BGP VRF- + value.description
    type: Service
    display_name: Check BGP VRF- + value.description
    file: zones.d/main/services/services.conf
    apply: true
    apply_for: key => value in host.vars.nb.config.bgp_sessions.vrf
    imports:
      - generic-service
    check_command: check_nwc_health
    assign:
      - host.vars.nb.platform == slx-os
    vars:
      check_nwc_mode: bgp-peer-status
      snmp_v3_context: key
...

here's the rendered Icinga2 object. Please note the quotes around value.description.

apply Service for (key => value in host.vars.nb.config.bgp_sessions.vrf)  {
  import "generic-service"

  display_name = "Check BGP VRF-" + "value.description"
  check_command = "check_nwc_health"
  assign where host.vars.nb.platform == "slx-os"
  vars.check_nwc_mode = "bgp-peer-status"
  vars.snmp_v3_context = key
}

These quotes need to be removed so that the GUI correctly displays the monitored services.

@lucagubler lucagubler linked a pull request Nov 11, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant