Skip to content

Commit

Permalink
Closes #34: Support for nested dict/list in config
Browse files Browse the repository at this point in the history
  • Loading branch information
gmazoyer committed Jul 10, 2024
1 parent 88ab1b0 commit 6d7a833
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion templates/configuration.py.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
{# # Copyright (c) 2017-2020 Guillaume Mazoyer under the GPL #}
# {{ ansible_managed }}

import json

DATABASE = {
'NAME': '{{ netbox_database }}',
'USER': '{{ netbox_database_user }}',
Expand Down Expand Up @@ -33,7 +35,9 @@ REMOTE_AUTH_BACKEND = 'netbox.authentication.LDAPBackend'
{% for setting, value in netbox_config.items() %}
{% if value in [True, False] %}
{{ setting }} = {{ 'True' if value else 'False' }}
{% else %}
{% elif value is number or value is string %}
{{ setting }} = {{ value | to_nice_json }}
{% else %}
{{ setting }} = json.loads(r"""{{ value | to_json }}""")
{% endif %}
{% endfor %}

0 comments on commit 6d7a833

Please sign in to comment.