{%- macro output(key, value) -%} {%- if value is string -%} {{key}} = {{value}} {%- elif value is iterable -%} {%- for item in value %} {{key}} = {{item}} {%- endfor -%} {%- else -%} {{key}} = {{value}} {%- endif -%} {%- endmacro -%} [Interface] {% for key, value in interface.items() -%} {{ output(key, value) }} {% endfor -%} {%- for peer in peers -%} [Peer] {% for key, value in peer.items() -%} {{ output(key, value) }} {% endfor -%} {%- endfor -%}