8000 Additional Jinja2 sequence/mapping fixes by alessfg · Pull Request #194 · nginx/ansible-role-nginx-config · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ BUG FIXES:
* NGINX listen `so_keepalive` parameter was not working as intended when setting specific values.
* Make sure all template objects are properly transformed into strings before doing Jinja2 operations.
* Remove unnecessary parentheses.
* Fix rewrite option in modules template.

## 0.4.1 (October 25, 2021)

Expand Down
4 changes: 2 additions & 2 deletions defaults/main/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ nginx_config_http_template:
etag: true # Boolean
if_modified_since: exact # Can be set to 'off', 'exact' or 'before'
ignore_invalid_headers: true # Boolean -- Not available in the 'location' context
include: path # Note -- This directive originally belongs in the NGINX core module, but we are making an exception here
include: path # String or list. Note -- This directive originally belongs in the NGINX core module, but we are making an exception here.
index: path # Note -- This directive originally belongs in the NGINX index module, but we are making an exception here
internal: false # Boolean -- Only available in the 'location' context
keepalive_disable: msie6 # String or a list
Expand Down Expand Up @@ -685,7 +685,7 @@ nginx_config_http_template:
last_modified: false # Boolean
once: true # Boolean
types: text/html # String or a list
custom_directives: # Custom directive for specific use cases not covered by templates -- you need to add a semi-colon at the end of each directive
custom_directives: # String or list. Custom directive for specific use cases not covered by templates -- you need to add a semi-colon at the end of each directive.
- fastcgi_split_path_info ^(.+\.php)(/.+)$;
- fastcgi_pass unix:/run/php/php7.2-fpm.sock;
servers:
Expand Down
4 changes: 2 additions & 2 deletions templates/http/auth.j2
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ auth_request_set {{ auth_request['set']['variable'] }} {{ auth_request['set']['v
auth_jwt {{ 'off' if not auth_jwt['enable'] }}{{ auth_jwt['enable']['realm'] if auth_jwt['enable']['realm'] is defined }}{{ (' token=' + auth_jwt['enable']['token'] | string) if auth_jwt['enable']['token'] is defined }};
{% endif %}
{% if auth_jwt['claim_set'] is defined %}{# 'claim_set' is only available in the 'http' context #}
{% for claim in auth_jwt['claim_set'] if (auth_jwt['claim_set'] is not mapping and auth_jwt['claim_set'] is not string) %}
{% for claim in auth_jwt['claim_set'] if auth_jwt['claim_set'] is not mapping %}
auth_jwt_claim_set {{ claim['variable'] }} {{ (claim['name'] if claim['name'] is string else claim['name'] | join(' ')) }};
{% else %}
auth_jwt_claim_set {{ auth_jwt['claim_set']['variable'] }} {{ (auth_jwt['claim_set']['name'] if auth_jwt['claim_set']['name'] is string else auth_jwt['claim_set']['name'] | join(' ')) }};
{% endfor %}
{% endif %}
{% if auth_jwt['header_set'] is defined %}{# 'header_set' is only available in the 'http' context #}
{% for claim in auth_jwt['header_set'] if (auth_jwt['header_set'] is not mapping and auth_jwt['header_set'] is not string) %}
{% for claim in auth_jwt['header_set'] if auth_jwt['header_set'] is not mapping %}
auth_jwt_header_set {{ claim['variable'] }} {{ (claim['name'] if claim['name'] is string else claim['name'] | join(' ')) }};
{% else %}
auth_jwt_header_set {{ auth_jwt['header_set']['variable'] }} {{ (auth_jwt['header_set']['name'] if auth_jwt['header_set']['name'] is string else auth_jwt['header_set']['name'] | join(' ')) }};
Expand Down
2 changes: 1 addition & 1 deletion templates/http/core.j2
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ if_modified_since {{ 'off' if not core['if_modified_since'] else core['if_modifi
{% if core['ignore_invalid_headers'] is defined and core['ignore_invalid_headers'] is boolean %}{# 'ignore_invalid_headers' directive is not available in the 'location' context #}
ignore_invalid_headers {{ core['ignore_invalid_headers'] | ternary('on', 'off') }};
{% endif %}
{% if core['include'] is defined and (core['include'] is string or core['include'] is sequence) %}{# ngx_core_module #}{# This does not belong here but we are making an exception #}
{% if core['include'] is defined and core['include'] is not mapping %}{# ngx_core_module #}{# This does not belong here but we are making an exception #}
{% for file in core['include'] if core['include'] is not string %}
include {{ file }};
{% else %}
Expand Down
6 changes: 3 additions & 3 deletions templates/http/default.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
{% from 'http/modules.j2' import sub_filter with context %}
{{ sub_filter(item['config']['sub_filter']) }}
{%- endif %}
{% if item['config']['custom_directives'] is defined and item['config']['custom_directives'] is sequence %}
{% if item['config']['custom_directives'] is defined and item['config']['custom_directives'] is not mapping %}
{% for directive in item['config']['custom_directives'] if item['config']['custom_directives'] is not string %}
{{ directive }}
{% else %}
Expand Down Expand Up @@ -222,7 +222,7 @@ server {
{{ sub_filter(server['sub_filter']) }}
{%- endfilter %}
{% endif %}
{% if server['custom_directives'] is defined and server['custom_directives'] is sequence %}
{% if server['custom_directives'] is defined and server['custom_directives'] is not mapping %}
{% for directive in server['custom_directives'] if server['custom_directives'] is not string %}
{% filter indent(4) %}
{{ directive }}
Expand Down Expand Up @@ -352,7 +352,7 @@ server {
{{ sub_filter(location['sub_filter']) }}
{%- endfilter %}
{% endif %}
{% if location['custom_directives'] is defined and location['custom_directives'] is sequence %}
{% if location['custom_directives'] is defined and location['custom_directives'] is not mapping %}
{% for directive in location['custom_directives'] if location['custom_directives'] is not string %}
{% filter indent(8) %}
{{ directive }}
Expand Down
6 changes: 4 additions & 2 deletions templates/http/modules.j2
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,17 @@ open_log_file_cache {{ 'off' if not log['open_log_file_cache'] else ('max=' + lo
return {{ rewrite['return'] if (rewrite['return'] is string or rewrite['return'] is number) }}{{ rewrite['return']['code'] if rewrite['return']['code'] is defined }}{{ (' ' + rewrite['return']['text'] | string) if rewrite['return']['text'] is defined }}{{ (' ' + rewrite['return']['url'] | string) if rewrite['return']['url'] is defined }};
{% endif %}
{% if rewrite['rewrites'] is defined %}{# 'rewrite' directive is not available in the 'http' context #}
{% for rewrite in rewrite['rewrites'] if (rewrite['rewrites'] is not mapping and rewrite['rewrites'] is not string) %}
{% for rewrite in rewrite['rewrites'] if rewrite['rewrites'] is not mapping %}
rewrite {{ rewrite['regex'] }} {{ rewrite['replacement'] }}{{ (' ' + rewrite['flag'] | string) if rewrite['flag'] is defined and rewrite['flag'] in ['last', 'break', 'redirect', 'permanent'] }};
{% else %}
rewrite {{ rewrite['rewrites']['regex'] }} {{ rewrite['rewrites']['replacement'] }}{{ (' ' + rewrite['rewrites']['flag'] | string) if rewrite['rewrites']['flag'] is defined and rewrite['rewrites']['flag'] in ['last', 'break', 'redirect', 'permanent'] }};
{% endfor %}
{% endif %}
{% if rewrite['log'] is defined and rewrite['log'] is boolean %}
rewrite_log {{ rewrite['log'] | ternary('on', 'off') }};
{% endif %}
{% if rewrite['set'] is defined %}{# 'set' directive is not available in the 'http' context #}
{% for set in rewrite['set'] if (rewrite['set'] is not mapping and rewrite['set'] is not string) %}
{% for set in rewrite['set'] if rewrite['set'] is not mapping %}
set {{ set['variable'] }} {{ set['value'] }};
{% else %}
set {{ rewrite['set']['variable'] }} {{ rewrite['set']['value'] }};
Expand Down
0