From fa8f962b97da1e15aa83154e718396def65f72bd Mon Sep 17 00:00:00 2001 From: Julien Pericat Date: Mon, 27 Aug 2018 14:28:01 +0200 Subject: [PATCH 1/2] Change: - fix #165 - introduce a sub variable nginx_upstreams.group - introduce a sub variable nginx_upstreams.port - if upstream.group is define, it'll loop over a given group - if upstream.group isn't define, upstream.servers is still mendatory - the user can set an optional port at nginx_upstreams.port --- templates/nginx.conf.j2 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/templates/nginx.conf.j2 b/templates/nginx.conf.j2 index 7cdec60..cb785a5 100644 --- a/templates/nginx.conf.j2 +++ b/templates/nginx.conf.j2 @@ -29,7 +29,7 @@ http { client_max_body_size {{ nginx_client_max_body_size }}; - log_format main {{ nginx_log_format|indent(23) }}; + log_format main {{ nginx_log_format|indent(23) }} access_log {{ nginx_access_log }}; @@ -60,9 +60,15 @@ http { {% if upstream.strategy is defined %} {{ upstream.strategy }}; {% endif %} +{% if upstream.group is defined %} +{% for host in groups[upstream.group] %} + server {{ hostvars[host]['ansible_default_ipv4']['address'] }}{% if upstream.port is defined %}:{{ upstream.port }}{% endif %}; +{% endfor %} +{% else %} {% for server in upstream.servers %} server {{ server }}; {% endfor %} +{% endif %} {% if upstream.keepalive is defined %} keepalive {{ upstream.keepalive }}; {% endif %} From 3b8bab429854ee57561b590ca20ebc70f452fb1b Mon Sep 17 00:00:00 2001 From: julien Date: Thu, 24 Dec 2020 13:55:01 -0500 Subject: [PATCH 2/2] fix: missing semi-colon --- templates/nginx.conf.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/nginx.conf.j2 b/templates/nginx.conf.j2 index cb785a5..e6002ea 100644 --- a/templates/nginx.conf.j2 +++ b/templates/nginx.conf.j2 @@ -29,7 +29,7 @@ http { client_max_body_size {{ nginx_client_max_body_size }}; - log_format main {{ nginx_log_format|indent(23) }} + log_format main {{ nginx_log_format|indent(23) }}; access_log {{ nginx_access_log }};