Skip to content

Commit

Permalink
Implement a new syntax to specify modules to be installed (#346)
Browse files Browse the repository at this point in the history
  • Loading branch information
alessfg committed Nov 12, 2020
1 parent bfbacd0 commit 121312d
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 13 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## 0.17.4 (November 12, 2020)

ENHANCEMENTS:

* 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:
```yaml
- name: njs # Required
state: present # Optional
version: =1.19.4+0.4.4-1~bionic # Optional
```
The old method of specifying modules (using a list of names) still works as expected.

## 0.17.3 (November 9, 2020)

ENHANCEMENTS:
Expand Down
8 changes: 6 additions & 2 deletions defaults/main/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ nginx_remove_license: true

# Install NGINX Modules.
# You can select any of the modules listed below. Beware of NGINX Plus only modules (these are marked).
# Default is no modules.
# Format is list with either the module name or a dictionary (see njs for an example).
# When using a dictionary, the default value for state is present, and for version it's nginx_version if specified.
# Default is an empty list (no modules are installed).
nginx_modules: []
# - auth-spnego # NGINX Plus
# - brotli # NGINX Plus
Expand All @@ -99,7 +101,9 @@ nginx_modules: []
# - headers-more # NGINX Plus
# - image-filter
# - lua # NGINX Plus
# - njs
# - name: njs # Required
# state: present # Optional
# version: =1.19.4+0.4.4-1~bionic # Optional
# - opentracing # NGINX Plus
# - passenger # NGINX Plus
# - perl # NGINX Plus
Expand Down
4 changes: 3 additions & 1 deletion molecule/common/playbooks/module_converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
- brotli
- geoip
- image-filter
- njs
- name: njs
# version: =1.19.4+0.4.4-1~bionic
state: present
- perl
- xslt
21 changes: 11 additions & 10 deletions tasks/modules/install-modules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,28 @@
- ansible_facts['distribution'] == "CentOS"
- '"geoip" in nginx_modules'

- name: Install NGINX Modules
- name: Install NGINX modules
package:
name: "nginx-{{ (nginx_type == 'plus') | ternary('plus-', '') }}module-{{ item }}{{ nginx_version | default('') }}"
state: present
name: "nginx-{{ (nginx_type == 'plus') | ternary('plus-', '') }}module-{{ item.name | default(item) }}\
{{ item.version | default(nginx_version) | default('') }}"
state: "{{ item.state | default('present') }}"
loop: "{{ nginx_modules }}"
when:
- (item in nginx_modules_list and nginx_type == 'opensource')
or (item in nginx_plus_modules_list and nginx_type == 'plus')
- not (item == "auth-spnego")
- (item.name | default(item) in nginx_modules_list and nginx_type == 'opensource')
or (item.name | default(item) in nginx_plus_modules_list and nginx_type == 'plus')
- not (item.name | default(item) == "auth-spnego")
or not (ansible_facts['os_family'] == "Alpine" and (ansible_facts['distribution_version'] | regex_search('^[0-9]+\\.[0-9]+') is version('3.8', '==')))
- not (item == "geoip")
- not (item.name | default(item) == "geoip")
or not ((ansible_facts['os_family'] == "RedHat" and ansible_facts['distribution_major_version'] is version('8', '=='))
or (ansible_facts['os_family'] == "FreeBSD"))
- not (item == "brotli")
- not (item.name | default(item) == "brotli")
or not ((ansible_facts['os_family'] == "Alpine")
or (ansible_facts['os_family'] == "RedHat" and ansible_facts['distribution_major_version'] is version('8', '<'))
or (ansible_facts['os_family'] == "Debian" and ansible_facts['distribution_major_version'] is version('9', '=='))
or (ansible_facts['os_family'] == "Suse" and ansible_facts['distribution_major_version'] is version('12', '<'))
or (ansible_facts['distribution'] == "Amazon")
or (ansible_facts['distribution'] == "OracleLinux"))
- not (item == "geoip2") or not (ansible_facts['os_family'] == "Suse")
- not (item == "opentracing")
- not (item.name | default(item) == "geoip2") or not (ansible_facts['os_family'] == "Suse")
- not (item.name | default(item) == "opentracing")
or not ((ansible_facts['os_family'] == "Suse" and ansible_facts['distribution_major_version'] is version('12', '=='))
or (ansible_facts['os_family'] == "RedHat" and ansible_facts['distribution_major_version'] is version('6', '==')))

0 comments on commit 121312d

Please sign in to comment.