gmazoyer / ansible-role-netbox

Ansible Role: NetBox
GNU General Public License v3.0
37 stars 22 forks source link

Rendering of Nested True/False Config Values not Giving the Expected Result #34

Closed seiichiro0185 closed 2 months ago

seiichiro0185 commented 3 months ago

Hi there, first of all thanks for creating this role. I am trying to add some config values for a plugin via the netbox_config variable, and it isn't giving the expected results. I'm not sure if this is a real bug, or if I just haven't found the correct syntax yet.

I have the following in my host_vars file for the netbox Host:

netbox_config:
  ALLOWED_HOSTS:
    - localhost
    - 127.0.0.1
    - netbox01.wired.lan
    - netbox.wired.lan
  TIME_ZONE: "Europe/Berlin"
  PLUGINS:
    - netbox_topology_views
  PLUGINS_CONFIG:
    netbox_topology_views:
      allow_coordinates_saving: True
      allways_save_coordinates: True

Everything up to the PLUGINS part renders correctly in the generated config. Unfortunately the "PLUGINS_CONFIG" part does not.

The correct config options would be like this:

PLUGINS_CONFIG = {
    "netbox_topology_views": {
        "allow_coordinates_saving": True,
        "allways_save_coordinates": True
    }
}

But what I actually get is this:

PLUGINS_CONFIG = {
    "netbox_topology_views": {
        "allow_coordinates_saving": true,
        "allways_save_coordinates": true
    }
}

Note the lowercase "true" - this does not work, netbox won't start like this. I also tried lowercase true in the yaml with the same result, and also quoting the "True" with single or double quotes in the yaml, which renders the quotes into the generated configuration, which does not work as well. Am I missing something here? Is there a special Syntax to get this to work?

Thanks in advance for any hints on solving this.

gmazoyer commented 3 months ago

This is an issue with the template rendering not handling boolean when they are nested into dictionary. You might be able to workaround this issue by quoting the values like "True" instead of True.

Anyway this needs a fix.

seiichiro0185 commented 2 months ago

Thanks for the quick fix, I can confirm that it works now.