Skip to content

Commit 121312d

Browse files
authored
Implement a new syntax to specify modules to be installed (#346)
1 parent bfbacd0 commit 121312d

File tree

4 files changed

+32
-13
lines changed

4 files changed

+32
-13
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# Changelog
22

3+
## 0.17.4 (November 12, 2020)
4+
5+
ENHANCEMENTS:
6+
7+
* Implement a new syntax to specify modules to be installed. You can now use the following format if you want further fine grained control over how you install modules:
8+
```yaml
9+
- name: njs # Required
10+
state: present # Optional
11+
version: =1.19.4+0.4.4-1~bionic # Optional
12+
```
13+
The old method of specifying modules (using a list of names) still works as expected.
14+
315
## 0.17.3 (November 9, 2020)
416
517
ENHANCEMENTS:

defaults/main/main.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ nginx_remove_license: true
8888

8989
# Install NGINX Modules.
9090
# You can select any of the modules listed below. Beware of NGINX Plus only modules (these are marked).
91-
# Default is no modules.
91+
# Format is list with either the module name or a dictionary (see njs for an example).
92+
# When using a dictionary, the default value for state is present, and for version it's nginx_version if specified.
93+
# Default is an empty list (no modules are installed).
9294
nginx_modules: []
9395
# - auth-spnego # NGINX Plus
9496
# - brotli # NGINX Plus
@@ -99,7 +101,9 @@ nginx_modules: []
99101
# - headers-more # NGINX Plus
100102
# - image-filter
101103
# - lua # NGINX Plus
102-
# - njs
104+
# - name: njs # Required
105+
# state: present # Optional
106+
# version: =1.19.4+0.4.4-1~bionic # Optional
103107
# - opentracing # NGINX Plus
104108
# - passenger # NGINX Plus
105109
# - perl # NGINX Plus

molecule/common/playbooks/module_converge.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
- brotli
2929
- geoip
3030
- image-filter
31-
- njs
31+
- name: njs
32+
# version: =1.19.4+0.4.4-1~bionic
33+
state: present
3234
- perl
3335
- xslt

tasks/modules/install-modules.yml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,28 @@
66
- ansible_facts['distribution'] == "CentOS"
77
- '"geoip" in nginx_modules'
88

9-
- name: Install NGINX Modules
9+
- name: Install NGINX modules
1010
package:
11-
name: "nginx-{{ (nginx_type == 'plus') | ternary('plus-', '') }}module-{{ item }}{{ nginx_version | default('') }}"
12-
state: present
11+
name: "nginx-{{ (nginx_type == 'plus') | ternary('plus-', '') }}module-{{ item.name | default(item) }}\
12+
{{ item.version | default(nginx_version) | default('') }}"
13+
state: "{{ item.state | default('present') }}"
1314
loop: "{{ nginx_modules }}"
1415
when:
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")
16+
- (item.name | default(item) in nginx_modules_list and nginx_type == 'opensource')
17+
or (item.name | default(item) in nginx_plus_modules_list and nginx_type == 'plus')
18+
- not (item.name | default(item) == "auth-spnego")
1819
or not (ansible_facts['os_family'] == "Alpine" and (ansible_facts['distribution_version'] | regex_search('^[0-9]+\\.[0-9]+') is version('3.8', '==')))
19-
- not (item == "geoip")
20+
- not (item.name | default(item) == "geoip")
2021
or not ((ansible_facts['os_family'] == "RedHat" and ansible_facts['distribution_major_version'] is version('8', '=='))
2122
or (ansible_facts['os_family'] == "FreeBSD"))
22-
- not (item == "brotli")
23+
- not (item.name | default(item) == "brotli")
2324
or not ((ansible_facts['os_family'] == "Alpine")
2425
or (ansible_facts['os_family'] == "RedHat" and ansible_facts['distribution_major_version'] is version('8', '<'))
2526
or (ansible_facts['os_family'] == "Debian" and ansible_facts['distribution_major_version'] is version('9', '=='))
2627
or (ansible_facts['os_family'] == "Suse" and ansible_facts['distribution_major_version'] is version('12', '<'))
2728
or (ansible_facts['distribution'] == "Amazon")
2829
or (ansible_facts['distribution'] == "OracleLinux"))
29-
- not (item == "geoip2") or not (ansible_facts['os_family'] == "Suse")
30-
- not (item == "opentracing")
30+
- not (item.name | default(item) == "geoip2") or not (ansible_facts['os_family'] == "Suse")
31+
- not (item.name | default(item) == "opentracing")
3132
or not ((ansible_facts['os_family'] == "Suse" and ansible_facts['distribution_major_version'] is version('12', '=='))
3233
or (ansible_facts['os_family'] == "RedHat" and ansible_facts['distribution_major_version'] is version('6', '==')))

0 commit comments

Comments
 (0)