Skip to content

Commit 9b9b3e8

Browse files
authored
Refactor modules (#315)
1 parent d12c3c5 commit 9b9b3e8

File tree

16 files changed

+102
-225
lines changed

16 files changed

+102
-225
lines changed

CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
# Changelog
22

3-
## 0.16.1 (Unreleased)
3+
## 0.17.0 (Unreleased)
4+
5+
BREAKING CHANGES:
6+
7+
* The process to install modules has changed. You will now have to use a list variable, `nginx_modules`, instead of manually setting the modules you want to install to `true` or `false`. This change will also simplify adding future supported modules to this role. You can find a list of supported modules for NGINX and NGINX Plus in [`vars/main.yml`](https://github.com/nginxinc/ansible-role-nginx/blob/master/vars/main.yml).
8+
* Modules can no longer be added to your NGINX config using this role. Please use the [`nginx_config`](https://github.com/nginxinc/ansible-role-nginx-config) role instead.
49

510
ENHANCEMENTS:
11+
612
* Update Ansible to `2.9.13` and Ansible Lint to `4.3.4`.
713

14+
BUG FIXES:
15+
16+
* NGINX Plus repository data for RedHat based distros is now appropriately set.
17+
818
## 0.16.0 (August 28, 2020)
919

1020
BREAKING CHANGES:

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,10 @@ This role has multiple variables. The descriptions and defaults for all these va
198198
- **[defaults/main/bsd.yml](https://github.com/nginxinc/ansible-role-nginx/blob/master/defaults/main/bsd.yml):** BSD installation variables
199199
- **[defaults/main/unit.yml](https://github.com/nginxinc/ansible-role-nginx/blob/master/defaults/main/unit.yml):** NGINX Unit installation variables
200200

201+
Similarly, descriptions and defaults for preset variables can be found in the **`vars`** directory:
202+
203+
- **[vars/main.yml](https://github.com/nginxinc/ansible-role-nginx/blob/master/vars/main.yml):** NGINX supported modules
204+
201205
Example Playbooks
202206
-----------------
203207

defaults/main/main.yml

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,28 @@ nginx_license:
8181
# Default is false.
8282
nginx_delete_license: false
8383

84-
# Install NGINX JavaScript, Perl, ModSecurity WAF (NGINX Plus only), GeoIP, Image-Filter, RTMP Media Streaming (NGINX Plus only), and/or XSLT modules.
85-
# Default is false.
86-
nginx_modules:
87-
njs: false
88-
perl: false
89-
waf: false
90-
geoip: false
91-
image_filter: false
92-
rtmp: false
93-
xslt: false
84+
# Install NGINX Modules.
85+
# You can select any of the modules listed below. Beware of NGINX Plus only modules (these are marked).
86+
# Default is no modules.
87+
nginx_modules: []
88+
# - auth-spnego # NGINX Plus
89+
# - brotli # NGINX Plus
90+
# - cookie-flag # NGINX Plus
91+
# - encrypted-session # NGINX Plus
92+
# - geoip
93+
# - geoip2 # NGINX Plus
94+
# - headers-more # NGINX Plus
95+
# - image-filter
96+
# - lua # NGINX Plus
97+
# - njs
98+
# - opentracing # NGINX Plus
99+
# - passenger # NGINX Plus
100+
# - perl # NGINX Plus
101+
# - prometheus # NGINX Plus
102+
# - rtmp
103+
# - subs-filter # NGINX Plus
104+
# - waf # NGINX Plus
105+
# - xslt
94106

95107
# Remove previously existing NGINX configuration files.
96108
# You can specify a list of paths you wish to remove.

molecule/common/playbooks/module_converge.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@
2424
- /etc/nginx/conf.d/default.conf
2525

2626
nginx_modules:
27-
njs: true
28-
perl: true
29-
waf: false
30-
geoip: true
31-
image_filter: true
32-
rtmp: true
33-
xslt: true
27+
- brotli
28+
- geoip
29+
- image-filter
30+
- njs
31+
- perl
32+
- xslt

tasks/main.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131

3232
- name: "(Install: All OSs) Install NGINX Modules"
3333
include_tasks: "{{ role_path }}/tasks/modules/install-modules.yml"
34-
when: true in nginx_modules.values()
34+
when:
35+
- nginx_modules is defined
36+
- nginx_modules | length > 0
3537
tags: nginx_install_modules
3638

3739
- name: "(Install: All OSs) Delete NGINX Plus License"

tasks/modules/install-geoip.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

tasks/modules/install-image-filter.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.

tasks/modules/install-modules.yml

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,32 @@
11
---
2-
- name: "(Install: All OSs) Install NGINX JavaScript Module"
3-
include_tasks: "{{ role_path }}/tasks/modules/install-njs.yml"
4-
when: nginx_modules.njs | default(false)
5-
6-
- name: "(Install: All OSs) Install NGINX Perl Module"
7-
include_tasks: "{{ role_path }}/tasks/modules/install-perl.yml"
8-
when: nginx_modules.perl | default(false)
9-
10-
- name: "(Install: All OSs) Install NGINX GeoIP Module"
11-
include_tasks: "{{ role_path }}/tasks/modules/install-geoip.yml"
12-
when:
13-
- nginx_modules.geoip | default(false)
14-
- ansible_os_family != "RedHat"
15-
- ansible_distribution_major_version != "8"
16-
17-
- name: "(Install: All OSs) Install NGINX Image Filter Module"
18-
include_tasks: "{{ role_path }}/tasks/modules/install-image-filter.yml"
19-
when: nginx_modules.image_filter | default(false)
20-
21-
- name: "(Install: All OSs) Install NGINX RTMP Module"
22-
include_tasks: "{{ role_path }}/tasks/modules/install-rtmp.yml"
2+
- name: "(Install: CentOS) Install GeoIP Required CentOS Dependencies"
3+
yum:
4+
name: epel-release
235
when:
24-
- nginx_modules.rtmp | default(false)
25-
- nginx_type == "plus"
26-
27-
- name: "(Install: All OSs) Install NGINX XSLT Module"
28-
include_tasks: "{{ role_path }}/tasks/modules/install-xslt.yml"
29-
when: nginx_modules.xslt | default(false)
6+
- ansible_distribution == "CentOS"
7+
- '"geoip" in nginx_modules'
308

31-
- name: "(Install: All OSs) Install NGINX WAF Module"
32-
include_tasks: "{{ role_path }}/tasks/modules/install-waf.yml"
9+
- name: "(Install: All OSs) Install NGINX Modules"
10+
package:
11+
name: "nginx-{{ (nginx_type == 'plus') | ternary('plus-', '') }}module-{{ item }}{{ nginx_version | default('') }}"
12+
state: present
13+
loop: "{{ nginx_modules }}"
3314
when:
34-
- nginx_modules.waf | default(false)
35-
- nginx_type == "plus"
15+
- (item in nginx_modules_list and nginx_type == 'opensource')
16+
or (item in nginx_plus_modules_list and nginx_type == 'plus')
17+
- not (item == "auth-spnego")
18+
or not (ansible_os_family == "Alpine" and (ansible_distribution_version | regex_search('^[0-9]+\\.[0-9]+') == "3.8"))
19+
- not (item == "geoip")
20+
or not ((ansible_os_family == "RedHat" and ansible_distribution_major_version == "8")
21+
or (ansible_os_family == "FreeBSD"))
22+
- not (item == "brotli")
23+
or not ((ansible_os_family == "Alpine")
24+
or (ansible_os_family == "RedHat" and ansible_distribution_major_version < "8")
25+
or (ansible_os_family == "Debian" and ansible_distribution_major_version == "9")
26+
or (ansible_os_family == "Suse" and ansible_distribution_major_version == "12")
27+
or (ansible_distribution == "Amazon")
28+
or (ansible_distribution == "OracleLinux"))
29+
- not (item == "geoip2") or not (ansible_os_family == "Suse")
30+
- not (item == "opentracing")
31+
or not ((ansible_os_family == "Suse" and ansible_distribution_major_version == "12")
32+
or (ansible_os_family == "RedHat" and ansible_distribution_major_version == "6"))

tasks/modules/install-njs.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

tasks/modules/install-perl.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)