diff --git a/pillar/role/matrix.sls b/pillar/role/matrix.sls index e4a27be..c26e004 100644 --- a/pillar/role/matrix.sls +++ b/pillar/role/matrix.sls @@ -193,6 +193,7 @@ nginx: enabled: True matrix.opensuse.org.conf: config: + - include: /etc/matrix-synapse/workers/upstreams.conf - server: - server_name: matrix.opensuse.org - listen: diff --git a/salt/profile/matrix/config.sls b/salt/profile/matrix/config.sls index 1e8b215..84dfd51 100644 --- a/salt/profile/matrix/config.sls +++ b/salt/profile/matrix/config.sls @@ -63,6 +63,14 @@ workers_nginx_file: - require: - file: workers_conf_dir +upstreams_nginx_file: + file.managed: + - name: /etc/matrix-synapse/workers/upstreams.conf + - source: salt://profile/matrix/files/upstreams.nginx + - template: jinja + - require: + - file: workers_conf_dir + {% set workers = salt['pillar.get']('profile:matrix:workers') %} {% for app, types in workers.items() %} diff --git a/salt/profile/matrix/files/upstreams.nginx b/salt/profile/matrix/files/upstreams.nginx new file mode 100644 index 0000000..65b3838 --- /dev/null +++ b/salt/profile/matrix/files/upstreams.nginx @@ -0,0 +1,14 @@ +{% set workers = salt['pillar.get']('profile:matrix:workers') %} + +{% for app, types in workers.items() %} +{% for type in types %} + +upstream {{ app }}_{{ loop.index }} { + {{ type.get('upstream_balancing') }} + {%- for worker, port in type.get('workers').items() %} + server 127.0.0.1:{{ port }}; # {{ worker }} + {%- endfor %} +} + +{% endfor %} +{% endfor %} diff --git a/salt/profile/matrix/files/workers.nginx b/salt/profile/matrix/files/workers.nginx index eab9606..0734e72 100644 --- a/salt/profile/matrix/files/workers.nginx +++ b/salt/profile/matrix/files/workers.nginx @@ -3,13 +3,6 @@ {% for app, types in workers.items() %} {% for type in types %} -upstream {{ app }}_{{ loop.index }} { - {{ type.get('upstream_balancing') }} - {%- for worker, port in type.get('workers').items() %} - server 127.0.0.1:{{ port }}; # {{ worker }} - {%- endfor %} -} - {%- if type.get('rest') is mapping %} {%- for uri in type.get('rest') %} location ~ {{ uri }} {