{% set tinc__tpl_directories = [] %}
{% for key, network in tinc__combined_networks.items() %}
{%   if network.state|d('present') != 'absent' %}
{% set _ = tinc__tpl_directories.append('tinc/networks/' + network.name | d(key) + '/by-group/all/hosts') %}
{% set _ = tinc__tpl_directories.append('tinc/networks/' + network.name | d(key) + '/by-network/' + network.name | d(key) + '/hosts') %}
{%     if network.inventory_groups|d() %}
{%       for group in ([ network.inventory_groups ] if network.inventory_groups is string else network.inventory_groups) %}
{% set _ = tinc__tpl_directories.append('tinc/networks/' + network.name | d(key) + '/by-group/' + group + '/hosts') %}
{%       if groups[group] %}
{%         for host in groups[group] %}
{%           if host == network.inventory_hostname | d(tinc__inventory_hostname) %}
{% set _ = tinc__tpl_directories.append('tinc/networks/' + network.name | d(key) + '/by-host/' + host + '/hosts') %}
{%           endif %}
{%         endfor %}
{%       endif %}
{%       endfor %}
{%     endif %}
{%     if tinc__inventory_hosts %}
{%       for host in tinc__inventory_hosts %}
{%         if host == network.inventory_hostname | d(tinc__inventory_hostname) %}
{% set _ = tinc__tpl_directories.append('tinc/networks/' + network.name | d(key) + '/by-host/' + host + '/hosts') %}
{%         endif %}
{%       endfor %}
{%     endif %}
{%   endif %}
{% endfor %}
{{ tinc__tpl_directories | to_yaml }}
