Skip to content

Commit 8b41c27

Browse files
authored
Improve the error formatting when there's a syntax error (#324)
And remove the debug tasks messages.
1 parent 5c7cfb0 commit 8b41c27

File tree

13 files changed

+18
-105
lines changed

13 files changed

+18
-105
lines changed

CHANGELOG.md

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

3-
## 0.17.0 (Unreleased)
3+
## 0.17.0 (September 18, 2020)
44

55
BREAKING CHANGES:
66

@@ -10,9 +10,8 @@ BREAKING CHANGES:
1010

1111
FEATURES:
1212

13-
* Two new variables have been introduced:
13+
* A new variable has been introduced:
1414
* `nginx_setup_license` -- Determine whether you want to use this role to upload your NGINX license to your target host.
15-
* `nginx_debug_tasks` -- Print task related information to give you a better insight into the current progress of the role.
1615
* The role will now fail automatically if you try to deploy NGINX from an official repository in an unsupported distribution. You can find a list of supported distributions for NGINX and NGINX Plus in [`vars/main.yml`](https://github.com/nginxinc/ansible-role-nginx/blob/main/vars/main.yml)
1716
* Three new tags have been introduced -- `nginx_setup_license`, `nginx_install` and `nginx_check_support`.
1817
* Add Alpine 3.12 to the list of supported platforms.

defaults/main/main.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ nginx_configure: false
1818
# Default is true.
1919
nginx_start: true
2020

21-
# Print NGINX task information to terminal during playbook execution.
22-
nginx_debug_tasks: false
2321
# Print NGINX configuration file to terminal after executing playbook.
2422
nginx_debug_output: false
2523

handlers/main.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
listen: "(Handler) Run NGINX"
77

88
- name: "(Handler) Print NGINX error if syntax check fails"
9-
fail:
10-
msg: "{{ config.stderr }}"
9+
debug:
10+
var: config.stderr_lines
11+
failed_when: config.rc != 0
1112
when: config.rc != 0
1213
listen: "(Handler) Run NGINX"
1314

@@ -30,13 +31,13 @@
3031
name: amplify-agent
3132
state: started
3233

33-
- name: "(Handler: Debian/Ubuntu/CentOS/RedHat) Start NGINX Unit"
34+
- name: "(DEPRECATED Handler: Debian/Ubuntu/CentOS/RedHat) Start NGINX Unit"
3435
service:
3536
name: unit
3637
state: started
3738
enabled: yes
3839

39-
- name: "(Handler: FreeBSD) Start NGINX Unit"
40+
- name: "(DEPRECATED Handler: FreeBSD) Start NGINX Unit"
4041
service:
4142
name: unitd
4243
state: started

tasks/config/debug-output.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
---
2-
- name: "Print NGINX config"
3-
debug:
4-
msg: "Printing NGINX config"
5-
when: nginx_debug_tasks | bool
6-
72
- name: "Register NGINX configuration"
8-
command: nginx -T
3+
command: "nginx -T"
94
changed_when: false
105
register: config
116

tasks/config/modify-systemd.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
---
2-
- name: "Modify systemd"
3-
debug:
4-
msg: "Modifying systemd"
5-
when: nginx_debug_tasks | bool
6-
72
- name: "Create override directory for NGINX systemd service"
83
file:
94
path: "{{ nginx_service_overridepath }}"
@@ -40,8 +35,3 @@
4035
state: absent
4136
when: nginx_service_clean | bool
4237
notify: "(Handler) Systemd daemon-reload"
43-
44-
- name: "Modify systemd"
45-
debug:
46-
msg: "Done modifying systemd"
47-
when: nginx_debug_tasks | bool

tasks/config/setup-logrotate.yml

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,28 @@
11
---
2-
- name: "Set up logrotate"
3-
debug:
4-
msg: "Setting up logrotate"
5-
when: nginx_debug_tasks | bool
6-
7-
- name: "(Alpine Linux OSs) Install logrotate"
2+
- name: "(Alpine Linux) Install logrotate"
83
apk:
94
name: logrotate
105
when: ansible_facts['os_family'] == "Alpine"
116

12-
- name: "(Debian OSs) Install logrotate"
7+
- name: "(Debian/Ubuntu) Install logrotate"
138
apt:
149
name: logrotate
1510
state: present
1611
when: ansible_facts['os_family'] == "Debian"
1712

18-
- name: "(Red Hat OSs) Install logrotate"
13+
- name: "(Amazon Linux/CentOS/Oracle Linux/RHEL) Install logrotate"
1914
yum:
2015
name: logrotate
2116
state: present
2217
when: ansible_facts['os_family'] == "RedHat"
2318

24-
- name: "(SLES OSs) Set up logrotate"
19+
- name: "(SLES) Set up logrotate"
2520
block:
26-
- name: "(SLES OSs) Configure logrotate repository"
21+
- name: "(SLES) Configure logrotate repository"
2722
zypper_repository:
2823
repo: https://download.opensuse.org/repositories/openSUSE:Leap:42.1/standard/openSUSE:Leap:42.1.repo
2924

30-
- name: "(SLES OSs) Install Logrotate"
25+
- name: "(SLES) Install Logrotate"
3126
zypper:
3227
name: logrotate
3328
state: present
@@ -39,8 +34,3 @@
3934
dest: "/etc/logrotate.d/nginx"
4035
mode: 0644
4136
notify: "(Handler) Run logrotate"
42-
43-
- name: "Set up logrotate"
44-
debug:
45-
msg: "Done setting up logrotate"
46-
when: nginx_debug_tasks | bool

tasks/keys/setup-keys.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
---
2-
- name: "Set up signing keys"
3-
debug:
4-
msg: "Setting up signing keys"
5-
when: nginx_debug_tasks | bool
6-
72
- name: "(Alpine Linux) Set up signing key"
83
block:
94
- name: "(Alpine Linux) Set up NGINX signing key URL"
@@ -34,8 +29,3 @@
3429
key: "{{ keysite }}"
3530
validate_certs: "{{ (ansible_facts['distribution_major_version'] is version('6', '==')) | ternary('no', 'yes') }}"
3631
when: ansible_facts['os_family'] in ['RedHat', 'Suse']
37-
38-
- name: "Set up signing keys"
39-
debug:
40-
msg: "Done setting up signing keys"
41-
when: nginx_debug_tasks | bool

tasks/opensource/install-oss.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
---
2-
- name: "Install NGINX"
3-
debug:
4-
msg: "Installing NGINX"
5-
when: nginx_debug_tasks | bool
6-
72
- name: "Install NGINX in Linux systems"
83
block:
94
- name: "Install NGINX from repository"
@@ -31,8 +26,3 @@
3126
- name: "Install NGINX in Unix systems"
3227
include_tasks: "{{ role_path }}/tasks/opensource/install-bsd.yml"
3328
when: ansible_facts['system'] | lower is search('bsd')
34-
35-
- name: "Install NGINX"
36-
debug:
37-
msg: "Done installing NGINX"
38-
when: nginx_debug_tasks | bool

tasks/plus/install-plus.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,8 @@
11
---
2-
- name: "Install NGINX Plus"
3-
debug:
4-
msg: "Installing NGINX Plus"
5-
when: nginx_debug_tasks | bool
6-
72
- name: "Set NGINX Plus repository"
83
set_fact:
94
repository: "{{ nginx_repository |
105
default(nginx_plus_default_repository[(ansible_facts['distribution'] == 'Amazon') | ternary('amazon', ansible_facts['os_family'] | lower)]) }}"
116

127
- name: "Install NGINX from repository"
138
include_tasks: "{{ role_path }}/tasks/plus/install-{{ ansible_facts['os_family'] | lower }}.yml"
14-
15-
- name: "Install NGINX Plus"
16-
debug:
17-
msg: "Done installing NGINX Plus"
18-
when: nginx_debug_tasks | bool

tasks/plus/setup-license.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
---
2-
- name: "Set up NGINX Plus license"
3-
debug:
4-
msg: "Setting up NGINX Plus license"
5-
when: nginx_debug_tasks | bool
6-
72
- name: "(Debian/Red Hat/SLES OSs) Set up NGINX Plus license"
83
block:
94
- name: "(Debian/Red Hat/SLES OSs) Create SSL directory"
@@ -45,8 +40,3 @@
4540
decrypt: yes
4641
mode: 0444
4742
when: ansible_facts['os_family'] == "Alpine"
48-
49-
- name: "Set up NGINX Plus license"
50-
debug:
51-
msg: "Done setting up NGINX Plus license"
52-
when: nginx_debug_tasks | bool

0 commit comments

Comments
 (0)