Fix errors when using Ansible's check mode (#339)

This commit is contained in:
Alessandro Fael Garcia 2020-10-28 20:12:57 +01:00 committed by GitHub
parent a4b40b2306
commit ab76f7a797
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 30 additions and 9 deletions

View File

@ -12,6 +12,7 @@ BUG FIXES:
* Prevent TravisCI from trying to build (and failing) NGINX Plus images on external PRs.
* Fix naming for SELinux facts dict.
* Role now runs correctly when using Ansible's check mode.
## 0.17.2 (September 24, 2020)

View File

@ -15,16 +15,19 @@
- name: (Handler) Check NGINX
command: nginx -t
register: config
register: config_check
ignore_errors: yes
check_mode: no
changed_when: false
listen: (Handler) Run NGINX
- name: (Handler) Print NGINX error if syntax check fails
debug:
var: config.stderr_lines
failed_when: config.rc != 0
when: config.rc != 0
var: config_check.stderr_lines
failed_when: config_check.rc != 0
when:
- config_check.stderr_lines is defined
- config_check.rc != 0
listen: (Handler) Run NGINX
- name: (Handler) Start NGINX Amplify agent

View File

@ -1,9 +1,12 @@
---
- name: Register NGINX config
command: nginx -T
ignore_errors: "{{ ansible_check_mode }}"
check_mode: no
changed_when: false
register: config
register: config_full
- name: Print NGINX config
debug:
var: config.stdout_lines
var: config_full.stdout_lines
when: config_full.stdout_lines is defined

View File

@ -11,4 +11,5 @@
repository: "{{ repository }}"
state: "{{ nginx_state }}"
update_cache: yes
ignore_errors: "{{ ansible_check_mode }}"
notify: (Handler) Run NGINX

View File

@ -66,12 +66,12 @@
- name: (DragonFlyBSD/HardenedBSD) Install NGINX
block:
- name: Install NGINX package
- name: (DragonFlyBSD/HardenedBSD) Install NGINX package
command: "pkg install www/nginx{{ nginx_version | default('') }}"
when: nginx_bsd_install_packages | bool
notify: (Handler) Run NGINX
- name: Install NGINX port
- name: (DragonFlyBSD/HardenedBSD) Install NGINX port
fail:
msg: "{{ ansible_facts['system'] }} Install NGINX port not implemented."
when: not nginx_bsd_install_packages | bool

View File

@ -11,4 +11,5 @@
apt:
name: "nginx{{ nginx_version | default('') }}"
state: "{{ nginx_state }}"
ignore_errors: "{{ ansible_check_mode }}"
notify: (Handler) Run NGINX

View File

@ -30,4 +30,5 @@
disablerepo: "*"
enablerepo: nginx
update_cache: yes
ignore_errors: "{{ ansible_check_mode }}"
notify: (Handler) Run NGINX

View File

@ -157,6 +157,7 @@
when:
- not pcre_result.stat.exists | bool
- not nginx_install_source_pcre | bool
- not ansible_check_mode | bool
- name: (Centos/RHEL) Install ZLib dependency from package
yum:
@ -216,6 +217,7 @@
when:
- not zlib_result.stat.exists | bool
- not nginx_install_source_zlib | bool
- not ansible_check_mode | bool
- name: (CentOS/RHEL) Install OpenSSL dependency from package
yum:
@ -275,6 +277,7 @@
when:
- not openssl_result.stat.exists | bool
- not nginx_install_source_openssl | bool
- not ansible_check_mode | bool
- name: Get NGINX version
block:
@ -284,6 +287,7 @@
return_content: yes
validate_certs: "{{ (ansible_facts['os_family'] == 'RedHat' and ansible_facts['distribution_major_version'] is version('6', '=='))
| ternary('no', 'yes') }}"
check_mode: no
register: nginx_versions
- name: Set NGINX mainline version
@ -430,7 +434,9 @@
command: rc-update add nginx default
when: ansible_facts['service_mgr'] == "openrc"
notify: (Handler) Run NGINX
when: not nginx_result.stat.exists
when:
- not nginx_result.stat.exists | bool
- not ansible_check_mode | bool
- name: Cleanup downloads
file:

View File

@ -10,4 +10,5 @@
state: "{{ nginx_state }}"
disable_recommends: no
update_cache: yes
ignore_errors: "{{ ansible_check_mode }}"
notify: (Handler) Run NGINX

View File

@ -11,4 +11,5 @@
name: "nginx-plus{{ nginx_version | default('') }}"
repository: "{{ repository }}"
state: "{{ nginx_state }}"
ignore_errors: "{{ ansible_check_mode }}"
notify: (Handler) Run NGINX

View File

@ -24,4 +24,5 @@
name: "nginx-plus{{ nginx_version | default('') }}"
state: "{{ nginx_state }}"
update_cache: yes
ignore_errors: "{{ ansible_check_mode }}"
notify: (Handler) Run NGINX

View File

@ -18,4 +18,5 @@
disablerepo: "*"
enablerepo: "nginx-plus"
update_cache: yes
ignore_errors: "{{ ansible_check_mode }}"
notify: (Handler) Run NGINX

View File

@ -16,4 +16,5 @@
name: "nginx-plus{{ nginx_version | default('') }}"
state: "{{ nginx_state }}"
update_cache: yes
ignore_errors: "{{ ansible_check_mode }}"
notify: (Handler) Run NGINX