Icinga / ansible-collection-icinga

Collection to setup and manage components of the Icinga software stack
Apache License 2.0
46 stars 35 forks source link

Bug when dict key is an integer #342

Open lucagubler opened 3 weeks ago

lucagubler commented 3 weeks ago

Hi all

I think there's a bug when we process a dict where the key is an integer. I added a JSON object to a device in NetBox and want to load and append this JSON to a Host object. The key is an AS number, e.g. 1234. Inside of the NetBox dict, this key is surrounded by quotes. However, the Icinga2Parser detects this as integer and doesn't add quotes around it, which will lead to an invalid config.

actual rendered example_host.conf

object Host "rt01zrh2.wlp.is" {
  ...
  vars.nb["config"] = {
    bgp_sessions = {
      asn = {
        1234 = "BGP 1"
        2345 = "BGP 2"
    }
  }
}

desired outcome with quotes around the AS number

object Host "rt01zrh2.wlp.is" {
  ...
  vars.nb["config"] = {
    bgp_sessions = {
      asn = {
        "1234" = "BGP 1"
        "2345" = "BGP 2"
    }
  }
}