#jinja2: trim_blocks: True, lstrip_blocks: True --- kubernetes: children: master: hosts: {% for item in bootstrap_nodes.master %} {{ item.name }}: ansible_user: {{ item.username }} ansible_host: {{ item.address }} {% endfor %} {% if bootstrap_nodes.worker | default([]) | length > 0 %} worker: hosts: {% for item in bootstrap_nodes.worker %} {{ item.name }}: ansible_user: {{ item.username }} ansible_host: {{ item.address }} {% endfor %} {% endif %}