Skip to content

Commit e9b6c59

Browse files
authored
Add separate variables for installing and configuring NGINX (#284)
1 parent 968bf3e commit e9b6c59

File tree

5 files changed

+65
-53
lines changed

5 files changed

+65
-53
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ FEATURES:
1212
* Add support to configure logrotate
1313
* Add support for Ubuntu Focal
1414
* Add support to configure SELinux
15+
* Two new variables have been introduced -- `nginx_install` and `nginx_configure` -- to let you choose whether you want to install NGINX, configure NGINX, or both
1516

1617
ENHANCEMENTS:
1718

18-
* Use `include_tasks` instead of `import_tasks` when possible to speed up the role's execution time
19+
* The role now uses `include_tasks` instead of `import_tasks` when possible to speed up the role's execution time
1920
* Improve configuration templating capabilities:
2021
* Add support for unix upstreams
2122
* Add PID templating option

defaults/main/linux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ nginx_linux_families: ['Alpine', 'Debian', 'RedHat', 'Suse']
77
# RedHat={Amazon,CentOS,OracleLinux,RHEL} Debian={Ubuntu,Debian}
88
nginx_plus_linux_families: ['Alpine', 'Debian', 'RedHat', 'Suse']
99

10-
# Default locations and versions for install from source
10+
# Default locations and versions when 'nginx_install_from; is set to 'source'
1111
pcre_version: pcre-8.43
1212
zlib_version: zlib-1.2.11
1313
openssl_version: openssl-1.1.1c

defaults/main/main.yml

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
---
2-
# Install NGINX.
2+
# Enable NGINX options -- `nginx_install` and `nginx_configure`.
33
# Default is true.
44
nginx_enable: true
55

6+
# Install NGINX and NGINX modules.
7+
# Variables for these options can be found below.
8+
# Default is true.
9+
nginx_install: true
10+
11+
# Enable NGINX configuration options.
12+
# Variables for these options can be found in `./template.yml` and `./upload.yml`.
13+
# Default is true.
14+
nginx_configure: true
15+
616
# Start NGINX service.
717
# Default is true.
818
nginx_start: true
@@ -22,7 +32,7 @@ nginx_type: opensource
2232
# nginx_version: "-20*"
2333

2434
# Specify whether you want to maintain your version of NGINX, upgrade to the latest version, or remove NGINX.
25-
# Can be used with `nginx_version` to achieve fine tune control on which version of NGINX is installed/used on each playbook execution.
35+
# Can be used with `nginx_version` to fine tune control on which version of NGINX is installed/used on each playbook execution.
2636
# Using 'present' will install the latest version (or 'nginx_version') of NGINX on a fresh install.
2737
# Using 'latest' will upgrade NGINX to the latest version (that matches your 'nginx_version') of NGINX on every playbook execution.
2838
# Using 'absent' will remove NGINX from your system.
@@ -36,14 +46,11 @@ nginx_state: present
3646
nginx_install_from: nginx_repository
3747

3848
# Specify source install options for NGINX Open Source.
39-
# Options represent whether to install from source also
40-
# or to install from packages (default). These only apply
41-
# if 'nginx_install_from' is set to 'source'
42-
# For the tools, true means we will install from a package
43-
# and false means install from source.
44-
# 'nginx_install_source_build_tools' will install compiler
45-
# and build tools from packages. If false, you need to have
46-
# these present.
49+
# Options represent whether to install from source also or to install from packages (default).
50+
# These only apply if 'nginx_install_from' is set to 'source'.
51+
# For the tools, true means we will install from a package and false means install from source.
52+
# 'nginx_install_source_build_tools' will install compiler and build tools from packages.
53+
# If false, you need to have these present.
4754
nginx_install_source_build_tools: true
4855
nginx_install_source_pcre: false
4956
nginx_install_source_openssl: true

molecule/common/playbook_default.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
- 80
3131
- 443
3232
nginx_version: "{{ version }}"
33+
nginx_configure: false
3334
nginx_logrotate_conf_enable: true
3435
nginx_logrotate_conf:
3536
paths:

tasks/main.yml

Lines changed: 44 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -18,46 +18,50 @@
1818
- name: "(Install: Debian/Ubuntu/CentOS/RedHat/FreeBSD) Install NGINX"
1919
block:
2020

21-
- include_tasks: "{{ role_path }}/tasks/opensource/install-oss.yml"
22-
when: nginx_type == "opensource"
23-
tags: nginx_install_oss
24-
25-
- include_tasks: "{{ role_path }}/tasks/plus/install-plus.yml"
26-
when: nginx_type == "plus"
27-
tags: nginx_install_plus
28-
29-
- include_tasks: "{{ role_path }}/tasks/conf/cleanup-config.yml"
30-
when: nginx_cleanup_config | bool
31-
tags: nginx_cleanup_config
32-
33-
- include_tasks: "{{ role_path }}/tasks/conf/upload-config.yml"
34-
when: nginx_main_upload_enable
35-
or nginx_http_upload_enable
36-
or nginx_stream_upload_enable
37-
or nginx_html_upload_enable
38-
or nginx_ssl_upload_enable
39-
tags: nginx_upload_config
40-
41-
- include_tasks: "{{ role_path }}/tasks/conf/template-config.yml"
42-
when: nginx_main_template_enable
43-
or nginx_http_template_enable
44-
or nginx_stream_template_enable
45-
or nginx_rest_api_enable
46-
tags: nginx_template_config
47-
48-
- include_tasks: "{{ role_path }}/tasks/conf/setup-status.yml"
49-
when: nginx_status_enable | bool
50-
tags: nginx_setup_status
51-
52-
- include_tasks: "{{ role_path }}/tasks/modules/install-modules.yml"
53-
when: true in nginx_modules.values()
54-
tags: nginx_install_modules
55-
56-
- include_tasks: "{{ role_path }}/tasks/plus/delete-license.yml"
57-
when:
58-
- nginx_type == "plus"
59-
- nginx_delete_license
60-
tags: nginx_delete_license
21+
- block:
22+
- include_tasks: "{{ role_path }}/tasks/opensource/install-oss.yml"
23+
when: nginx_type == "opensource"
24+
tags: nginx_install_oss
25+
26+
- include_tasks: "{{ role_path }}/tasks/plus/install-plus.yml"
27+
when: nginx_type == "plus"
28+
tags: nginx_install_plus
29+
30+
- include_tasks: "{{ role_path }}/tasks/modules/install-modules.yml"
31+
when: true in nginx_modules.values()
32+
tags: nginx_install_modules
33+
34+
- include_tasks: "{{ role_path }}/tasks/plus/delete-license.yml"
35+
when:
36+
- nginx_type == "plus"
37+
- nginx_delete_license
38+
tags: nginx_delete_license
39+
when: nginx_install | bool
40+
41+
- block:
42+
- include_tasks: "{{ role_path }}/tasks/conf/cleanup-config.yml"
43+
when: nginx_cleanup_config | bool
44+
tags: nginx_cleanup_config
45+
46+
- include_tasks: "{{ role_path }}/tasks/conf/upload-config.yml"
47+
when: nginx_main_upload_enable
48+
or nginx_http_upload_enable
49+
or nginx_stream_upload_enable
50+
or nginx_html_upload_enable
51+
or nginx_ssl_upload_enable
52+
tags: nginx_upload_config
53+
54+
- include_tasks: "{{ role_path }}/tasks/conf/template-config.yml"
55+
when: nginx_main_template_enable
56+
or nginx_http_template_enable
57+
or nginx_stream_template_enable
58+
or nginx_rest_api_enable
59+
tags: nginx_template_config
60+
61+
- include_tasks: "{{ role_path }}/tasks/conf/setup-status.yml"
62+
when: nginx_status_enable | bool
63+
tags: nginx_setup_status
64+
when: nginx_configure | bool
6165

6266
- name: "(Config: All OSs) Ensure NGINX is Running"
6367
meta: flush_handlers
@@ -69,7 +73,6 @@
6973
- include_tasks: "{{ role_path }}/tasks/conf/logrotate.yml"
7074
when: nginx_logrotate_conf_enable | bool
7175
tags: nginx_logrotate_config
72-
7376
when: nginx_enable | bool
7477

7578
- include_tasks: "{{ role_path }}/tasks/amplify/install-amplify.yml"

0 commit comments

Comments
 (0)