Skip to content

Commit 6710550

Browse files
authored
Support include in the main NGINX context (#302)
1 parent 333b95b commit 6710550

File tree

6 files changed

+22
-3
lines changed

6 files changed

+22
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
ENHANCEMENTS:
66

7-
Bump the Ansible `community.general` collection to `6.2.0` and `community.docker` collection to `3.4.0`.
7+
* Support the `include` directive in the main NGINX context.
8+
* Bump the Ansible `community.general` collection to `6.2.0` and `community.docker` collection to `3.4.0`.
89

910
BUG FIXES:
1011

defaults/main/template.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,14 @@ nginx_config_main_template:
6464
# use: epoll
6565
# worker_aio_requests: 32 # Number
6666
worker_connections: 1024 # Number
67+
# include: # String or a list of strings
68+
# - /etc/nginx/modules.conf
6769
http:
6870
include: # String or a list of strings
6971
- /etc/nginx/mime.types
7072
- /etc/nginx/conf.d/*.conf
7173
# stream:
72-
# include: # String or a list of strings
73-
# - /etc/nginx/conf.d/stream/*.conf
74+
# include: /etc/nginx/conf.d/stream/*.conf # String or a list of strings
7475

7576
# Enable creating dynamic templated NGINX HTTP configuration files.
7677
# Defaults will not produce a valid configuration. Instead they are meant to showcase
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
load_module modules/ngx_http_perl_module.so;

molecule/default/converge.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
nginx_config_selinux_tcp_ports:
1313
- 80
1414

15+
nginx_config_upload_enable: true
16+
nginx_config_upload:
17+
- src: ../common/files/snippets/modules.conf
18+
dest: /etc/nginx/modules.conf
19+
1520
nginx_config_upload_ssl_enable: true
1621
nginx_config_upload_ssl_crt:
1722
- src: ../common/files/ssl/molecule.crt
@@ -69,6 +74,8 @@
6974
use: epoll
7075
worker_aio_requests: 32
7176
worker_connections: 512
77+
include:
78+
- /etc/nginx/modules.conf
7279
http:
7380
include:
7481
- /etc/nginx/conf.d/*.conf

molecule/default/prepare.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
vars:
99
nginx_modules:
1010
- njs
11+
- perl

templates/nginx.conf.j2

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55
{{ main(nginx_config_main_template['config']['main']) }}
66
{%- endif %}
77

8+
{% if nginx_config_main_template['config']['include'] is defined and nginx_config_main_template['config']['include'] is not mapping %}
9+
{% for file in nginx_config_main_template['config']['include'] if nginx_config_main_template['config']['include'] is not string %}
10+
include {{ file }};
11+
{% else %}
12+
include {{ nginx_config_main_template['config']['include'] }};
13+
{% endfor %}
14+
{%- endif %}
15+
816
events {
917
{% if nginx_config_main_template['config']['events'] is defined %}
1018
{% from 'core.j2' import events with context %}

0 commit comments

Comments
 (0)