{% set workers = salt['pillar.get']('profile:matrix:workers') %}
{% for app, types in workers.items() %}
{% for type in types %}
upstream {{ app }}_{{ loop.index }} {
{%- if type.get('upstream_balancing') %}
{{ type.get('upstream_balancing') }}
{% endif -%}
{%- for worker, port in type.get('workers').items() %}
server 127.0.0.1:{{ port }}; # {{ worker }}
{%- endfor %}
}
{% endfor %}
{% endfor %}