#jinja2: lstrip_blocks: True {{ ansible_managed | comment }} DEVICE={{ item.key }} {% for key, value in item.value.items() %} {% if key | lower == "dns" and not value is string and value is iterable %} {% for item in value -%} DNS{{ loop.index }}={{ item }} {% endfor %} {% else %} {{- key | upper }}={{ value }} {% endif %} {% endfor %}