Skip to content

Commit 9760f98

Browse files
committed
Add NGINX Plus tests to TravisCI (#327)
1 parent 2ca5ce8 commit 9760f98

File tree

19 files changed

+73
-32
lines changed

19 files changed

+73
-32
lines changed

.travis.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ jobs:
2424
- name: (CentOS) Cleanup config and try to install modules
2525
env:
2626
scenario: module_centos
27+
- name: (Debian/Ubuntu) Install NGINX Plus
28+
env:
29+
scenario: plus
30+
- name: (Alpine Linux) Install NGINX Plus
31+
env:
32+
scenario: plus_alpine
33+
- name: (CentOS) Install NGINX Plus
34+
env:
35+
scenario: plus_centos
2736
- name: (Debian/Ubuntu) Install stable branch and push a config
2837
env:
2938
scenario: stable_push
@@ -73,6 +82,5 @@ install:
7382
- pip install docker==4.3.1
7483
script:
7584
- travis_wait 50 molecule test -s $scenario
76-
7785
notifications:
7886
webhooks: https://galaxy.ansible.com/api/v1/notifications/

CHANGELOG.md

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

3-
## 0.17.0 (September 19, 2020)
3+
## 0.17.0 (September 20, 2020)
44

55
BREAKING CHANGES:
66

@@ -16,10 +16,12 @@ FEATURES:
1616
* Three new tags have been introduced -- `nginx_setup_license`, `nginx_install` and `nginx_check_support`.
1717
* Add Alpine 3.12 to the list of supported platforms.
1818
* Remove Alpine 3.8 from the list of supported platforms.
19+
* Add NGINX Plus tests to TravisCI
1920

2021
ENHANCEMENTS:
2122

2223
* Added handlers to check for NGINX syntax validity and fail if any errors are detected.
24+
* Switch to using `ansible_facts` wherever possible.
2325
* Major backend refactoring to reduce the number of files and tasks.
2426
* You can now specify an `nginx_repository` for NGINX Plus too.
2527
* Moved "constant" variables to `vars/main.yml`.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ Working functional playbook examples can be found in the **`molecule/common/`**
181181

182182
- **[molecule/common/playbooks/default_converge.yml](https://github.com/nginxinc/ansible-role-nginx/blob/main/molecule/common/playbooks/default_converge.yml):** Install a specific version of NGINX and set up logrotate
183183
- **[molecule/common/playbooks/module_converge.yml](https://github.com/nginxinc/ansible-role-nginx/blob/main/molecule/common/playbooks/module_converge.yml):** Install various NGINX supported modules
184+
- **[molecule/common/playbooks/plus_converge.yml](https://github.com/nginxinc/ansible-role-nginx/blob/main/molecule/common/playbooks/plus_converge.yml):** Install NGINX Plus and various NGINX Plus supported modules
184185
- **[molecule/common/playbooks/source_converge.yml](https://github.com/nginxinc/ansible-role-nginx/blob/main/molecule/common/playbooks/source_converge.yml):** Install NGINX from source
185186
- **[molecule/common/playbooks/stable_push_converge.yml](https://github.com/nginxinc/ansible-role-nginx/blob/main/molecule/common/playbooks/stable_push_converge.yml):** Install NGINX using the stable branch and push a preexisting config from your system to your NGINX instance
186187
- **[molecule/common/playbooks/template_converge.yml](https://github.com/nginxinc/ansible-role-nginx/blob/main/molecule/common/playbooks/template_converge.yml):** Use the NGINX configuration templating variables to create an NGINX configuration file

defaults/main/main.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ nginx_debug_output: false
2626
# Default is 'opensource'.
2727
nginx_type: opensource
2828

29-
# Specify which version of NGINX you want to install.
30-
# Default is empty.
29+
# (Optional) Specify which version of NGINX you want to install.
30+
# Default is to install the latest release.
3131
# nginx_version: "=19-1~bionic"
3232
# For NGINX Plus and modules you'll need a wilcard like below (which installs plus-20 and modules)
3333
# nginx_version: "-20*"
@@ -57,11 +57,11 @@ nginx_install_source_pcre: false
5757
nginx_install_source_openssl: true
5858
nginx_install_source_zlib: false
5959

60-
# Choose where to fetch the NGINX signing key from.
60+
# (Optional) Choose where to fetch the NGINX signing key from.
6161
# Default is the official NGINX signing key host.
6262
# nginx_signing_key: http://nginx.org/keys/nginx_signing.key
6363

64-
# Specify repository for NGINX Open Source or NGINX Plus.
64+
# (Optional) Specify repository for NGINX Open Source or NGINX Plus.
6565
# Only works if 'install_from' is set to 'nginx_repository' when installing NGINX Open Source.
6666
# Defaults are the official NGINX repositories.
6767
# nginx_repository: deb [arch=amd64] https://nginx.org/packages/mainline/debian/ buster nginx
@@ -83,8 +83,8 @@ nginx_license:
8383
nginx_setup_license: true
8484

8585
# Remove NGINX Plus license and repository after installation for security purposes.
86-
# Default is false.
87-
nginx_remove_license: false
86+
# Default is true.
87+
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).

handlers/main.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
---
2+
- name: (Handler) Systemd daemon-reload
3+
systemd:
4+
daemon_reload: yes
5+
26
- name: (Handler) Check NGINX
37
command: nginx -t
48
register: config
@@ -12,10 +16,6 @@
1216
when: config.rc != 0
1317
listen: (Handler) Run NGINX
1418

15-
- name: (Handler) Systemd daemon-reload
16-
systemd:
17-
daemon_reload: yes
18-
1919
- name: (Handler) Start/Reload NGINX
2020
service:
2121
name: nginx
@@ -24,7 +24,7 @@
2424
when:
2525
- nginx_start | bool
2626
- not ansible_check_mode | bool
27-
listen: "(Handler) Run NGINX"
27+
listen: (Handler) Run NGINX
2828

2929
- name: (Handler) Start NGINX Amplify agent
3030
service:

molecule/common/playbooks/plus_converge.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
vars:
99
nginx_type: plus
1010
nginx_license:
11-
certificate: ../../ansible-role-nginx/files/license/nginx-repo.crt
12-
key: ../../ansible-role-nginx/files/license/nginx-repo.key
11+
certificate: license/nginx-repo.crt
12+
key: license/nginx-repo.key
13+
nginx_remove_license: false
1314
nginx_modules:
1415
- auth-spnego
1516
- brotli
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
- name: Prepare
3+
hosts: localhost
4+
gather_facts: false
5+
tasks:
6+
- name: Create ephemeral license certificate file from b64 decoded env var
7+
copy:
8+
content: "{{ lookup('env','NGINX_CRT') | b64decode }}"
9+
dest: ../../../files/license/nginx-repo.crt
10+
force: no
11+
mode: 0444
12+
13+
- name: Create ephemeral license key file from b64 decoded env var
14+
copy:
15+
content: "{{ lookup('env','NGINX_KEY') | b64decode }}"
16+
dest: ../../../files/license/nginx-repo.key
17+
force: no
18+
mode: 0444

molecule/common/playbooks/plus_verify.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
- name: Verify
33
hosts: all
44
tasks:
5+
- name: Check if NGINX is installed
6+
package:
7+
name: nginx-plus
8+
check_mode: yes
9+
register: install
10+
failed_when: (install is changed) or (install is failed)
11+
512
- name: Check if NGINX service is running
613
service:
714
name: nginx

molecule/plus/molecule.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,6 @@ platforms:
4444
provisioner:
4545
name: ansible
4646
playbooks:
47+
prepare: ../common/playbooks/plus_prepare.yml
4748
converge: ../common/playbooks/plus_converge.yml
4849
verify: ../common/playbooks/plus_verify.yml

molecule/plus_alpine/molecule.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@ platforms:
3030
provisioner:
3131
name: ansible
3232
playbooks:
33+
prepare: ../common/playbooks/plus_prepare.yml
3334
converge: ../common/playbooks/plus_converge.yml
3435
verify: ../common/playbooks/plus_verify.yml

molecule/plus_centos/molecule.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@ platforms:
3030
provisioner:
3131
name: ansible
3232
playbooks:
33+
prepare: ../common/playbooks/plus_prepare.yml
3334
converge: ../common/playbooks/plus_converge.yml
3435
verify: ../common/playbooks/plus_verify.yml

tasks/plus/install-debian.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@
1515
apt_repository:
1616
filename: nginx-plus
1717
repo: "{{ repository }}"
18-
update_cache: yes
18+
update_cache: no
1919
state: "{{ nginx_license_status | default ('present') }}"
2020
mode: 0644
2121

2222
- name: (Debian/Ubuntu) Install NGINX Plus
2323
apt:
2424
name: "nginx-plus{{ nginx_version | default('') }}"
2525
state: "{{ nginx_state }}"
26+
update_cache: yes
2627
notify: (Handler) Run NGINX

templates/http/api.conf.j2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{# DEPRECATED #}
12
{{ ansible_managed | comment }}
23

34
server {

templates/http/default.conf.j2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{# DEPRECATED #}
12
{{ ansible_managed | comment }}
23

34
{% if item.value.upstreams is defined and item.value.upstreams %}

templates/http/status.conf.j2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{# DEPRECATED #}
12
{{ ansible_managed | comment }}
23

34
server {

templates/nginx.conf.j2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{# DEPRECATED #}
12
{{ ansible_managed | comment }}
23

34
user {{ nginx_main_template.user }};

templates/stream/default.conf.j2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{# DEPRECATED #}
12
{{ ansible_managed | comment }}
23

34
{% if item.value.upstreams is defined %}

templates/www/index.html.j2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<!-- DEPRECATED -->
12
<!-- {{ ansible_managed }} -->
23

34
<!DOCTYPE html>

vars/main.yml

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,15 @@ nginx_default_repository:
3434

3535
# Default NGINX Plus repositories
3636
nginx_plus_default_repository:
37-
alpine: >-
38-
https://plus-pkgs.nginx.com/alpine/v{{ ansible_facts['distribution_version'] | regex_search('^[0-9]+\.[0-9]+') }}/main
39-
amazon: >-
40-
https://plus-pkgs.nginx.com/amzn{{ (ansible_facts['distribution_version'] is version('2', '=='))
41-
| ternary('2', '') }}/$releasever/$basearch
42-
debian: >-
43-
deb [arch=amd64] https://plus-pkgs.nginx.com/{{ ansible_facts['distribution'] | lower }} {{ ansible_facts['distribution_release'] }} nginx-plus
44-
freebsd: >-
45-
https://plus-pkgs.nginx.com/freebsd/${ABI}/latest
46-
redhat: >-
47-
https://plus-pkgs.nginx.com/{{ (ansible_facts['distribution'] == "CentOS")
48-
| ternary('centos', 'rhel') }}/{{ (ansible_facts['distribution_version'] is version('7.4', '>=')
49-
and ansible_facts['distribution_version'] is version('8', '<')) | ternary('7.4', ansible_facts['distribution_major_version']) }}/$basearch/
50-
suse: >-
51-
https://plus-pkgs.nginx.com/sles/{{ ansible_facts['distribution_major_version'] }}?ssl_clientcert=/etc/ssl/nginx/nginx-repo-bundle.crt&ssl_verify=host
37+
alpine: "https://plus-pkgs.nginx.com/alpine/v{{ ansible_facts['distribution_version'] | regex_search('^[0-9]+\\.[0-9]+') }}/main"
38+
amazon: "https://plus-pkgs.nginx.com/amzn{{ (ansible_facts['distribution_version'] is version('2', '==')) | ternary('2', '') }}/$releasever/$basearch"
39+
debian: "deb [arch=amd64] https://plus-pkgs.nginx.com/{{ ansible_facts['distribution'] | lower }} {{ ansible_facts['distribution_release'] }} nginx-plus"
40+
freebsd: "https://plus-pkgs.nginx.com/freebsd/${ABI}/latest"
41+
redhat: "https://plus-pkgs.nginx.com/{{ (ansible_facts['distribution'] == 'CentOS')
42+
| ternary('centos', 'rhel') }}/{{ (ansible_facts['distribution_version'] is version('7.4', '>=')
43+
and ansible_facts['distribution_version'] is version('8', '<')) | ternary('7.4', ansible_facts['distribution_major_version']) }}/$basearch/"
44+
suse: "https://plus-pkgs.nginx.com/sles/{{ ansible_facts['distribution_major_version'] }}\
45+
?ssl_clientcert=/etc/ssl/nginx/nginx-repo-bundle.crt&ssl_verify=host"
5246

5347
# Alpine dependencies
5448
nginx_alpine_dependencies: [
@@ -72,7 +66,7 @@ nginx_sles_dependencies: [
7266

7367
# FreeBSD dependencies
7468
nginx_freebsd_dependencies: [
75-
'security/ca_root_nss'
69+
'security/ca_root_nss',
7670
]
7771

7872
# Default locations and versions when 'nginx_install_from' is set to 'source'

0 commit comments

Comments
 (0)