#jinja2: trim_blocks: True, lstrip_blocks: True {% for item in groups[nft_managed_group] | sort %} {% set client = hostvars[item] %} {% if 'nft_dst' in client and client.nft_dst is not none %} {% set target_ip = client.container_ip %} {% for client in client.nft_dst %} {% set ports = client.port if (client.port is iterable and client.port is not string) else [client.port] %} {% set protos = client.proto if (client.proto is iterable and client.proto is not string) else [client.proto] %} {% set ifaces = client.iface if (client.iface is iterable and client.iface is not string) else [client.iface] %} {% for proto in protos %} {% for port in ports %} {% for iface in ifaces %} iifname "{{ iface }}" {{ proto }} dport {{ port }} counter dnat ip to {{ target_ip }}:{{ port }} comment "{{ iface }} -> {{ item }}" {% endfor %} {% endfor %} {% endfor %} {% endfor %} {% endif %} {% endfor %}