Skip to content

Commit b21decd

Browse files
authored
Merge branch 'main' into gzip-static
2 parents bd6af6a + 98e899d commit b21decd

File tree

7 files changed

+96
-9
lines changed

7 files changed

+96
-9
lines changed

CHANGELOG.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@ FEATURES:
66

77
- Add validation tasks to check the Ansible version, the Jinja2 version, and whether the required Ansible collections for this role are installed.
88
- Bump the Ansible `community.general` collection to `9.2.0`, `community.crypto` collection to `2.21.1` and `community.docker` collection to `3.11.0`.
9-
- Add templating support for the `ngx_http_gzip_static_module` NGINX module.
9+
- Add templating support for the `ngx_http_gzip_static_module` and NGINX modules.
1010

1111
BUG FIXES:
1212

1313
- Fix the default path for the stream template deployment location.
1414
- Fix incompatibility when using the `listen` directive and setting both the `quic` and `so_keepalive` parameters.
1515
- Correct cleanup error when `nginx_config_cleanup_paths` is not defined.
16-
- Disable check_mode for validation task `jinja2_version`.
16+
- Disable check_mode for `jinja2_version` and Ansible collections validation tasks.
1717
- The default PID path has changed as of NGINX 1.27.5 and 1.28.0.
18+
- Properly wrap `http_version` number in quotes in both the template defaults and Molecule tests.
19+
- NGINX `set_real_ip_from` directive template parameter should be a list.
1820

1921
TESTS:
2022

defaults/main/template.yml

+12-1
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ nginx_config_http_template:
436436
headers_hash_bucket_size: 64
437437
headers_hash_max_size: 512
438438
hide_header: Date # String or a list of strings
439-
http_version: 1.1 # Can be set to '1.0' or '1.1'
439+
http_version: '1.1' # Can be set to '1.0' or '1.1'
440440
ignore_client_abort: false # Boolean
441441
ignore_headers: X-Accel-Redirect # String or a list of strings -- Can be set to 'X-Accel-Redirect', 'X-Accel-Expires', 'X-Accel-Limit-Rate', 'X-Accel-Buffering', 'X-Accel-Charset', 'Expires', 'Cache-Control', 'Set-Cookie' or 'Vary'
442442
intercept_errors: false # Boolean
@@ -962,6 +962,17 @@ nginx_config_stream_template:
962962
inactive: 20s
963963
min_uses: 2 # Number
964964
valid: 1m
965+
map: # Configure maps -- Available only in the 'stream' context
966+
hash_bucket_size: 64
967+
hash_max_size: 2048
968+
mappings: # List of dictionaries
969+
- string: $remote_addr # Required
970+
variable: $upstream # Required
971+
hostnames: false # Boolean
972+
volatile: false # Boolean
973+
content: # Dictionary or list of dictionaries
974+
- value: default
975+
new_value: 0
965976
custom_directives: # String or a list of strings. Custom directive for specific use cases not covered by templates. Note: You need to include each directive in its full form. Make sure you add a semi-colon or closing curly bracket at the end of each directive.
966977
- server {};
967978
servers: # All previous modules are also available (when allowed) in the 'servers' context.

molecule/complete/converge.yml

+20-2
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@
349349
hide_header:
350350
- Date
351351
- X-Accel-Redirect
352-
http_version: 1.1
352+
http_version: '1.1'
353353
ignore_client_abort: false
354354
ignore_headers:
355355
- X-Accel-Redirect
@@ -460,7 +460,7 @@
460460
comp_level: 1
461461
disable:
462462
- '"msie6"'
463-
http_version: 1.1
463+
http_version: '1.1'
464464
min_length: 20
465465
proxied:
466466
- expired
@@ -855,6 +855,24 @@
855855
inactive: 20s
856856
min_uses: 2
857857
valid: 1m
858+
map:
859+
hash_bucket_size: 128
860+
hash_max_size: 4096
861+
mappings:
862+
- string: $hostname
863+
variable: $stream_name
864+
hostnames: true
865+
volatile: true
866+
content:
867+
- value: example.com
868+
new_value: 3
869+
- string: $host
870+
variable: $isblockaccess_ua
871+
content:
872+
- value: default
873+
new_value: 0
874+
- value: '"~jndi:ldap"'
875+
new_value: 2
858876
servers:
859877
- core:
860878
listen:

molecule/complete_plus/converge.yml

+22-3
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@
208208
comp_level: 1
209209
disable:
210210
- '"msie6"'
211-
http_version: 1.1
211+
http_version: '1.1'
212212
min_length: 20
213213
proxied:
214214
- expired
@@ -316,7 +316,8 @@
316316
- value: '"~jndi:ldap"'
317317
new_value: 1
318318
realip:
319-
set_real_ip_from: 0.0.0.0
319+
set_real_ip_from:
320+
- 0.0.0.0
320321
real_ip_header: X-Real-IP
321322
real_ip_recursive: false
322323
rewrite:
@@ -478,7 +479,7 @@
478479
hide_header:
479480
- Date
480481
- X-Accel-Redirect
481-
http_version: 1.1
482+
http_version: '1.1'
482483
ignore_client_abort: false
483484
ignore_headers:
484485
- X-Accel-Redirect
@@ -769,6 +770,24 @@
769770
inactive: 20s
770771
min_uses: 2
771772
valid: 1m
773+
map:
774+
hash_bucket_size: 128
775+
hash_max_size: 4096
776+
mappings:
777+
- string: $hostname
778+
variable: $stream_name
779+
hostnames: true
780+
volatile: true
781+
content:
782+
- value: example.com
783+
new_value: 3
784+
- string: $host
785+
variable: $isblockaccess_ua
786+
content:
787+
- value: default
788+
new_value: 0
789+
- value: '"~jndi:ldap"'
790+
new_value: 2
772791
servers:
773792
- core:
774793
listen:

tasks/validate/validate.yml

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
ansible.builtin.command: ansible-galaxy collection list
3333
register: collection_list
3434
changed_when: false
35+
check_mode: false
3536

3637
- name: Verify that the 'community.general' Ansible collection is installed on your Ansible host
3738
ansible.builtin.assert:

templates/http/modules.j2

+5-1
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,12 @@ mirror_request_body {{ mirror['request_body'] | ternary('on', 'off') }};
257257

258258
{# NGINX HTTP RealIP -- ngx_http_realip_module #}
259259
{% macro realip(realip) %}
260-
{% if realip['set_real_ip_from'] is defined %}
260+
{% if realip['set_real_ip_from'] is defined and realip['set_real_ip_from'] is not mapping %}
261+
{% for set_real_ip_from in realip['set_real_ip_from'] if realip['set_real_ip_from'] is not string %}
262+
set_real_ip_from {{ set_real_ip_from }};
263+
{% else %}
261264
set_real_ip_from {{ realip['set_real_ip_from'] }};
265+
{% endfor %}
262266
{% endif %}
263267
{% if realip['real_ip_header'] is defined %}
264268
real_ip_header {{ realip['real_ip_header'] }};

templates/stream/modules.j2

+32
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,35 @@ open_log_file_cache {{ 'off' if not log['open_log_file_cache'] else ('max=' + lo
7979
{% endif %}
8080

8181
{% endmacro %}
82+
83+
{# NGINX Stream Map -- ngx_stream_map_module #}
84+
{% macro map(map) %}{# 'map' module is only available in the 'stream' context #}
85+
{% if map['hash_bucket_size'] is defined %}
86+
map_hash_bucket_size {{ map['hash_bucket_size'] }};
87+
{% endif %}
88+
{% if map['hash_max_size'] is defined %}
89+
map_hash_max_size {{ map['hash_max_size'] }};
90+
{% endif %}
91+
{% if map['mappings'] is defined %}
92+
{% for map_data in map['mappings'] %}
93+
{% if map_data['string'] is defined and map_data['variable'] is defined %}
94+
map {{ map_data['string'] }} {{ map_data['variable'] }} {
95+
{% if map_data['hostnames'] is defined and map_data['hostnames'] is boolean and map_data['hostnames'] | bool %}
96+
hostnames;
97+
{% endif %}
98+
{% if map_data['volatile'] is defined and map_data['volatile'] is boolean and map_data['volatile'] | bool %}
99+
volatile;
100+
{% endif %}
101+
{% if map_data['content'] is defined %}
102+
{% for content_line in map_data['content'] if map_data['content'] is not mapping %}
103+
{{ content_line['value'] }} {{ content_line['new_value'] }};
104+
{% else %}
105+
{{ map_data['content']['value'] }} {{ map_data['content']['new_value'] }};
106+
{% endfor %}
107+
{% endif %}
108+
}
109+
{% endif %}
110+
{% endfor %}
111+
{% endif %}
112+
113+
{% endmacro %}

0 commit comments

Comments
 (0)