#jinja2: lstrip_blocks: True {% macro clause_attr(key, value) %} {% if value is boolean %} {{ key }}: {{ 'yes' if value else 'no' }} {% elif value is iterable and not value is string %} {% for item in value %} {{ key }}: {{ item }} {% endfor %} {% else %} {{ key }}: {{ value }} {% endif %} {% endmacro %} {% if unbound_config_include_conf_d %} include-toplevel: "/etc/unbound/unbound.conf.d/*.conf" {% endif %} {% for clause, clause_items in unbound_config.items() %} {% if clause_items.values()|reject('mapping')|length != 0 %} {{ clause }}: {% for key, value in clause_items.items() %} {{ clause_attr(key, value) }} {%- endfor %} {% else %} {% for clause_key, clause_instance_items in clause_items.items() %} {{ clause }}: name: "{{ clause_key }}" {% for key, value in clause_instance_items.items() %} {{ clause_attr(key, value) }} {%- endfor %} {% endfor %} {% endif %} {% endfor %} {{ unbound_config_raw }}