Skip to content

Commit

Permalink
Support include in the main NGINX context (#302)
Browse files Browse the repository at this point in the history
  • Loading branch information
alessfg authored Jan 17, 2023
1 parent 333b95b commit 6710550
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

ENHANCEMENTS:

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

BUG FIXES:

Expand Down
5 changes: 3 additions & 2 deletions defaults/main/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,14 @@ nginx_config_main_template:
# use: epoll
# worker_aio_requests: 32 # Number
worker_connections: 1024 # Number
# include: # String or a list of strings
# - /etc/nginx/modules.conf
http:
include: # String or a list of strings
- /etc/nginx/mime.types
- /etc/nginx/conf.d/*.conf
# stream:
# include: # String or a list of strings
# - /etc/nginx/conf.d/stream/*.conf
# include: /etc/nginx/conf.d/stream/*.conf # String or a list of strings

# Enable creating dynamic templated NGINX HTTP configuration files.
# Defaults will not produce a valid configuration. Instead they are meant to showcase
Expand Down
1 change: 1 addition & 0 deletions molecule/common/files/snippets/modules.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
load_module modules/ngx_http_perl_module.so;
7 changes: 7 additions & 0 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
nginx_config_selinux_tcp_ports:
- 80

nginx_config_upload_enable: true
nginx_config_upload:
- src: ../common/files/snippets/modules.conf
dest: /etc/nginx/modules.conf

nginx_config_upload_ssl_enable: true
nginx_config_upload_ssl_crt:
- src: ../common/files/ssl/molecule.crt
Expand Down Expand Up @@ -69,6 +74,8 @@
use: epoll
worker_aio_requests: 32
worker_connections: 512
include:
- /etc/nginx/modules.conf
http:
include:
- /etc/nginx/conf.d/*.conf
Expand Down
1 change: 1 addition & 0 deletions molecule/default/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
vars:
nginx_modules:
- njs
- perl
8 changes: 8 additions & 0 deletions templates/nginx.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
{{ main(nginx_config_main_template['config']['main']) }}
{%- endif %}

{% if nginx_config_main_template['config']['include'] is defined and nginx_config_main_template['config']['include'] is not mapping %}
{% for file in nginx_config_main_template['config']['include'] if nginx_config_main_template['config']['include'] is not string %}
include {{ file }};
{% else %}
include {{ nginx_config_main_template['config']['include'] }};
{% endfor %}
{%- endif %}

events {
{% if nginx_config_main_template['config']['events'] is defined %}
{% from 'core.j2' import events with context %}
Expand Down

0 comments on commit 6710550

Please sign in to comment.