Improve the error formatting when there's a syntax error (#324)

And remove the debug tasks messages.
This commit is contained in:
Alessandro Fael Garcia 2020-09-18 19:51:50 +02:00 committed by GitHub
parent 5c7cfb05fb
commit 8b41c27cb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 18 additions and 105 deletions

View File

@ -1,6 +1,6 @@
# Changelog # Changelog
## 0.17.0 (Unreleased) ## 0.17.0 (September 18, 2020)
BREAKING CHANGES: BREAKING CHANGES:
@ -10,9 +10,8 @@ BREAKING CHANGES:
FEATURES: FEATURES:
* Two new variables have been introduced: * A new variable has been introduced:
* `nginx_setup_license` -- Determine whether you want to use this role to upload your NGINX license to your target host. * `nginx_setup_license` -- Determine whether you want to use this role to upload your NGINX license to your target host.
* `nginx_debug_tasks` -- Print task related information to give you a better insight into the current progress of the role.
* 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) * 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)
* Three new tags have been introduced -- `nginx_setup_license`, `nginx_install` and `nginx_check_support`. * Three new tags have been introduced -- `nginx_setup_license`, `nginx_install` and `nginx_check_support`.
* Add Alpine 3.12 to the list of supported platforms. * Add Alpine 3.12 to the list of supported platforms.

View File

@ -18,8 +18,6 @@ nginx_configure: false
# Default is true. # Default is true.
nginx_start: true nginx_start: true
# Print NGINX task information to terminal during playbook execution.
nginx_debug_tasks: false
# Print NGINX configuration file to terminal after executing playbook. # Print NGINX configuration file to terminal after executing playbook.
nginx_debug_output: false nginx_debug_output: false

View File

@ -6,8 +6,9 @@
listen: "(Handler) Run NGINX" listen: "(Handler) Run NGINX"
- name: "(Handler) Print NGINX error if syntax check fails" - name: "(Handler) Print NGINX error if syntax check fails"
fail: debug:
msg: "{{ config.stderr }}" var: config.stderr_lines
failed_when: config.rc != 0
when: config.rc != 0 when: config.rc != 0
listen: "(Handler) Run NGINX" listen: "(Handler) Run NGINX"
@ -30,13 +31,13 @@
name: amplify-agent name: amplify-agent
state: started state: started
- name: "(Handler: Debian/Ubuntu/CentOS/RedHat) Start NGINX Unit" - name: "(DEPRECATED Handler: Debian/Ubuntu/CentOS/RedHat) Start NGINX Unit"
service: service:
name: unit name: unit
state: started state: started
enabled: yes enabled: yes
- name: "(Handler: FreeBSD) Start NGINX Unit" - name: "(DEPRECATED Handler: FreeBSD) Start NGINX Unit"
service: service:
name: unitd name: unitd
state: started state: started

View File

@ -1,11 +1,6 @@
--- ---
- name: "Print NGINX config"
debug:
msg: "Printing NGINX config"
when: nginx_debug_tasks | bool
- name: "Register NGINX configuration" - name: "Register NGINX configuration"
command: nginx -T command: "nginx -T"
changed_when: false changed_when: false
register: config register: config

View File

@ -1,9 +1,4 @@
--- ---
- name: "Modify systemd"
debug:
msg: "Modifying systemd"
when: nginx_debug_tasks | bool
- name: "Create override directory for NGINX systemd service" - name: "Create override directory for NGINX systemd service"
file: file:
path: "{{ nginx_service_overridepath }}" path: "{{ nginx_service_overridepath }}"
@ -40,8 +35,3 @@
state: absent state: absent
when: nginx_service_clean | bool when: nginx_service_clean | bool
notify: "(Handler) Systemd daemon-reload" notify: "(Handler) Systemd daemon-reload"
- name: "Modify systemd"
debug:
msg: "Done modifying systemd"
when: nginx_debug_tasks | bool

View File

@ -1,33 +1,28 @@
--- ---
- name: "Set up logrotate" - name: "(Alpine Linux) Install logrotate"
debug:
msg: "Setting up logrotate"
when: nginx_debug_tasks | bool
- name: "(Alpine Linux OSs) Install logrotate"
apk: apk:
name: logrotate name: logrotate
when: ansible_facts['os_family'] == "Alpine" when: ansible_facts['os_family'] == "Alpine"
- name: "(Debian OSs) Install logrotate" - name: "(Debian/Ubuntu) Install logrotate"
apt: apt:
name: logrotate name: logrotate
state: present state: present
when: ansible_facts['os_family'] == "Debian" when: ansible_facts['os_family'] == "Debian"
- name: "(Red Hat OSs) Install logrotate" - name: "(Amazon Linux/CentOS/Oracle Linux/RHEL) Install logrotate"
yum: yum:
name: logrotate name: logrotate
state: present state: present
when: ansible_facts['os_family'] == "RedHat" when: ansible_facts['os_family'] == "RedHat"
- name: "(SLES OSs) Set up logrotate" - name: "(SLES) Set up logrotate"
block: block:
- name: "(SLES OSs) Configure logrotate repository" - name: "(SLES) Configure logrotate repository"
zypper_repository: zypper_repository:
repo: https://download.opensuse.org/repositories/openSUSE:Leap:42.1/standard/openSUSE:Leap:42.1.repo repo: https://download.opensuse.org/repositories/openSUSE:Leap:42.1/standard/openSUSE:Leap:42.1.repo
- name: "(SLES OSs) Install Logrotate" - name: "(SLES) Install Logrotate"
zypper: zypper:
name: logrotate name: logrotate
state: present state: present
@ -39,8 +34,3 @@
dest: "/etc/logrotate.d/nginx" dest: "/etc/logrotate.d/nginx"
mode: 0644 mode: 0644
notify: "(Handler) Run logrotate" notify: "(Handler) Run logrotate"
- name: "Set up logrotate"
debug:
msg: "Done setting up logrotate"
when: nginx_debug_tasks | bool

View File

@ -1,9 +1,4 @@
--- ---
- name: "Set up signing keys"
debug:
msg: "Setting up signing keys"
when: nginx_debug_tasks | bool
- name: "(Alpine Linux) Set up signing key" - name: "(Alpine Linux) Set up signing key"
block: block:
- name: "(Alpine Linux) Set up NGINX signing key URL" - name: "(Alpine Linux) Set up NGINX signing key URL"
@ -34,8 +29,3 @@
key: "{{ keysite }}" key: "{{ keysite }}"
validate_certs: "{{ (ansible_facts['distribution_major_version'] is version('6', '==')) | ternary('no', 'yes') }}" validate_certs: "{{ (ansible_facts['distribution_major_version'] is version('6', '==')) | ternary('no', 'yes') }}"
when: ansible_facts['os_family'] in ['RedHat', 'Suse'] when: ansible_facts['os_family'] in ['RedHat', 'Suse']
- name: "Set up signing keys"
debug:
msg: "Done setting up signing keys"
when: nginx_debug_tasks | bool

View File

@ -1,9 +1,4 @@
--- ---
- name: "Install NGINX"
debug:
msg: "Installing NGINX"
when: nginx_debug_tasks | bool
- name: "Install NGINX in Linux systems" - name: "Install NGINX in Linux systems"
block: block:
- name: "Install NGINX from repository" - name: "Install NGINX from repository"
@ -31,8 +26,3 @@
- name: "Install NGINX in Unix systems" - name: "Install NGINX in Unix systems"
include_tasks: "{{ role_path }}/tasks/opensource/install-bsd.yml" include_tasks: "{{ role_path }}/tasks/opensource/install-bsd.yml"
when: ansible_facts['system'] | lower is search('bsd') when: ansible_facts['system'] | lower is search('bsd')
- name: "Install NGINX"
debug:
msg: "Done installing NGINX"
when: nginx_debug_tasks | bool

View File

@ -1,9 +1,4 @@
--- ---
- name: "Install NGINX Plus"
debug:
msg: "Installing NGINX Plus"
when: nginx_debug_tasks | bool
- name: "Set NGINX Plus repository" - name: "Set NGINX Plus repository"
set_fact: set_fact:
repository: "{{ nginx_repository | repository: "{{ nginx_repository |
@ -11,8 +6,3 @@
- name: "Install NGINX from repository" - name: "Install NGINX from repository"
include_tasks: "{{ role_path }}/tasks/plus/install-{{ ansible_facts['os_family'] | lower }}.yml" include_tasks: "{{ role_path }}/tasks/plus/install-{{ ansible_facts['os_family'] | lower }}.yml"
- name: "Install NGINX Plus"
debug:
msg: "Done installing NGINX Plus"
when: nginx_debug_tasks | bool

View File

@ -1,9 +1,4 @@
--- ---
- name: "Set up NGINX Plus license"
debug:
msg: "Setting up NGINX Plus license"
when: nginx_debug_tasks | bool
- name: "(Debian/Red Hat/SLES OSs) Set up NGINX Plus license" - name: "(Debian/Red Hat/SLES OSs) Set up NGINX Plus license"
block: block:
- name: "(Debian/Red Hat/SLES OSs) Create SSL directory" - name: "(Debian/Red Hat/SLES OSs) Create SSL directory"
@ -45,8 +40,3 @@
decrypt: yes decrypt: yes
mode: 0444 mode: 0444
when: ansible_facts['os_family'] == "Alpine" when: ansible_facts['os_family'] == "Alpine"
- name: "Set up NGINX Plus license"
debug:
msg: "Done setting up NGINX Plus license"
when: nginx_debug_tasks | bool

View File

@ -1,24 +1,9 @@
--- ---
- name: "Install dependencies"
debug:
msg: "Installing dependencies"
when: nginx_debug_tasks | bool
- name: "Install dependencies" - name: "Install dependencies"
include_tasks: "{{ role_path }}/tasks/prerequisites/install-dependencies.yml" include_tasks: "{{ role_path }}/tasks/prerequisites/install-dependencies.yml"
- name: "Install dependencies"
debug:
msg: "Done installing dependencies"
when: nginx_debug_tasks | bool
- name: "Set up SELinux" - name: "Set up SELinux"
block: block:
- name: "Set up SELinux"
debug:
msg: "Setting up SELinux"
when: nginx_debug_tasks | bool
- name: "Check if SELinux is enabled" - name: "Check if SELinux is enabled"
debug: debug:
msg: "You need to enable SELinux, if it was disabled you need to reboot" msg: "You need to enable SELinux, if it was disabled you need to reboot"
@ -27,11 +12,6 @@
- name: "Configure SELinux" - name: "Configure SELinux"
include_tasks: "{{ role_path }}/tasks/prerequisites/setup-selinux.yml" include_tasks: "{{ role_path }}/tasks/prerequisites/setup-selinux.yml"
when: ansible_facts['selinux.mode'] is defined when: ansible_facts['selinux.mode'] is defined
- name: "Set up SELinux"
debug:
msg: "Done setting up SELinux"
when: nginx_debug_tasks | bool
when: when:
- nginx_selinux | bool - nginx_selinux | bool
- ansible_facts['os_family'] in ['RedHat', 'Suse'] - ansible_facts['os_family'] in ['RedHat', 'Suse']

View File

@ -6,7 +6,7 @@
state: present state: present
loop: "{{ nginx_unit_modules }}" loop: "{{ nginx_unit_modules }}"
when: ansible_facts['os_family'] != "FreeBSD" when: ansible_facts['os_family'] != "FreeBSD"
notify: "(Handler: Debian/Ubuntu/CentOS/RedHat) Start NGINX Unit" notify: "(DEPRECATED Handler: Debian/Ubuntu/CentOS/RedHat) Start NGINX Unit"
- name: "(FreeBSD) Install NGINX Unit Modules" - name: "(FreeBSD) Install NGINX Unit Modules"
portinstall: portinstall:
@ -14,4 +14,4 @@
state: present state: present
loop: "{{ nginx_unit_modules }}" loop: "{{ nginx_unit_modules }}"
when: ansible_facts['os_family'] == "FreeBSD" when: ansible_facts['os_family'] == "FreeBSD"
notify: "(Handler: FreeBSD) Start NGINX Unit" notify: "(DEPRECATED Handler: FreeBSD) Start NGINX Unit"

View File

@ -15,14 +15,14 @@
name: unit name: unit
state: present state: present
when: ansible_facts['os_family'] != "FreeBSD" when: ansible_facts['os_family'] != "FreeBSD"
notify: "(Handler: Debian/Ubuntu/CentOS/RedHat) Start NGINX Unit" notify: "(DEPRECATED Handler: Debian/Ubuntu/CentOS/RedHat) Start NGINX Unit"
- name: "(DEPRECATED) Install NGINX Unit" - name: "(DEPRECATED) Install NGINX Unit"
portinstall: portinstall:
name: unit name: unit
state: present state: present
when: ansible_facts['os_family'] == "FreeBSD" when: ansible_facts['os_family'] == "FreeBSD"
notify: "(Handler: FreeBSD) Start NGINX Unit" notify: "(DEPRECATED Handler: FreeBSD) Start NGINX Unit"
- name: "(DEPRECATED) Install NGINX Unit modules" - name: "(DEPRECATED) Install NGINX Unit modules"
include_tasks: "{{ role_path }}/tasks/unit/install-modules.yml" include_tasks: "{{ role_path }}/tasks/unit/install-modules.yml"