From 21bd776e75ed222401bde0d9f8ae9b21e03f7fca Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Mon, 25 May 2020 11:22:18 +0200 Subject: [PATCH] use a list for nginx_error_location --- defaults/main.yml | 10 +++++----- templates/etc/nginx/sites-available/vhost.j2 | 18 +++++++++--------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 72a0b11..ef98fd1 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -107,17 +107,17 @@ nginx_error_page: [] # dest: /4xx.html # @end +nginx_error_location: [] # @var nginx_error_location: description: > # Default error location. If set, the defined location will be automatically added once # to every server block to handle custom error sites. # @end -# @var nginx_error_location:default: $ "_unset_" # @var nginx_error_location: example: > # nginx_error_location: -# match: / -# root: /var/www/vhosts/default -# index: index.html -# custom_options: +# - match: / +# root: /var/www/vhosts/default +# index: index.html +# custom_options: # @end nginx_vhosts_dir: /var/www/vhosts diff --git a/templates/etc/nginx/sites-available/vhost.j2 b/templates/etc/nginx/sites-available/vhost.j2 index 6709e1b..31ca8c2 100644 --- a/templates/etc/nginx/sites-available/vhost.j2 +++ b/templates/etc/nginx/sites-available/vhost.j2 @@ -90,22 +90,22 @@ server { {% endfor %} {% endif %} - {% if nginx_error_location is defined %} - location {{ nginx_error_location.match }} { - {% if nginx_error_location.root is defined and nginx_error_location.root %} - root {{ nginx_error_location.root }}; + {% for error_location in nginx_error_location %} + location {{ error_location.match }} { + {% if error_location.root is defined and error_location.root %} + root {{ error_location.root }}; {% endif %} - {% if nginx_error_location.index is defined and nginx_error_location.index %} - index {{ nginx_error_location.index }}; + {% if error_location.index is defined and error_location.index %} + index {{ error_location.index }}; {% endif %} - {% if nginx_error_location.custom_options is defined and nginx_error_location.custom_options %} + {% if error_location.custom_options is defined and error_location.custom_options %} - {% for inline_option in nginx_error_location.custom_options %} + {% for inline_option in error_location.custom_options %} {{ inline_option }}; {% endfor %} {% endif %} } - {% endif %} + {% endfor %} } {% endfor %}