diff --git a/framework/internal/render.py b/framework/internal/render.py index bc37bb5..bce47bd 100644 --- a/framework/internal/render.py +++ b/framework/internal/render.py @@ -11,6 +11,7 @@ 'path_exists': lambda path: os.path.exists(path), 'read_file': lambda path: open(path).read(), 'oneline': lambda text: ''.join(text.splitlines()), + 'list': lambda iter: list(iter), } def render(node_name: str, dry: bool = False) -> None: diff --git a/templates/file-server/routers.json.j2 b/templates/file-server/routers.json.j2 index b2f6ed3..d49b5ba 100644 --- a/templates/file-server/routers.json.j2 +++ b/templates/file-server/routers.json.j2 @@ -1,13 +1,14 @@ { {% for name, data in hostvars.items() %} - "{{ name }}": { - "name": "{{ data['site_name'] }}", - "ip_addresses": ["{{ data['host_ip'] }}"], - "host": "{{ data['ansible_host'] }}", - "prefix": "{{ data['default_prefix'] }}", - "shortname": "{{ name }}", - "position": {{ data['position'] }} - } - {%- if not loop.last -%},{% endif %} + {{ name | tojson }}: {{{ + 'shortname': name, + 'name': data['site_name'], + 'ip_addresses': [data['host_ip']], + 'host': data['ansible_host'], + 'prefix': data['default_prefix'], + 'neighbors': list(neighbors.keys()), + 'position': data['position'], + } | tojson }} + {% if not loop.last %},{% endif %} {% endfor %} } \ No newline at end of file