Skip to content

Commit 6d7a833

Browse files
committed
Closes #34: Support for nested dict/list in config
1 parent 88ab1b0 commit 6d7a833

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

templates/configuration.py.j2

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
{# # Copyright (c) 2017-2020 Guillaume Mazoyer under the GPL #}
33
# {{ ansible_managed }}
44

5+
import json
6+
57
DATABASE = {
68
'NAME': '{{ netbox_database }}',
79
'USER': '{{ netbox_database_user }}',
@@ -33,7 +35,9 @@ REMOTE_AUTH_BACKEND = 'netbox.authentication.LDAPBackend'
3335
{% for setting, value in netbox_config.items() %}
3436
{% if value in [True, False] %}
3537
{{ setting }} = {{ 'True' if value else 'False' }}
36-
{% else %}
38+
{% elif value is number or value is string %}
3739
{{ setting }} = {{ value | to_nice_json }}
40+
{% else %}
41+
{{ setting }} = json.loads(r"""{{ value | to_json }}""")
3842
{% endif %}
3943
{% endfor %}

0 commit comments

Comments
 (0)