ansible-nginx/templates/etc/nginx/conf.d/_upstream.conf.j2

20 lines
686 B
Plaintext
Raw Normal View History

2015-10-08 23:21:40 +07:00
{%- macro s(key, value, is_bool, min_version) %}
{% if nginx_version.stdout is version(min_version, 'ge') %}
2015-10-09 19:36:55 +07:00
{% if is_bool and value %} {{ key }}{% elif not is_bool %} {{ key }}={{ value }}{% endif %}
2015-10-08 23:21:40 +07:00
{% endif %}
{%- endmacro -%}
#
# {{ ansible_managed }}
#
upstream {{ item.name }} {
{% for server in item.servers %}
2015-10-09 22:54:07 +07:00
server {{ server.path }}{% for p in nginx_upstream_server_params if server[p.key] is defined %}{{ s(p.key, server[p.key] | default(p.default), p.is_bool | default(false), p.min_version | default('0.0.1')) }}{% endfor %};
2015-10-08 23:21:40 +07:00
{% endfor %}
{% if item.params is defined and item.params is iterable %}
{% for param in item.params %}
{{ param }};
{% endfor %}
{% endif %}
}