Skip to content

Commit 1495588

Browse files
authored
Fix check mode (#38)
1 parent e8bc926 commit 1495588

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ BUG FIXES:
1717
* Prevent TravisCI from trying to build (and failing) NGINX Plus images on external PRs.
1818
* Fix naming for SELinux Ansible facts.
1919
* Correctly import `app_protect` global directives in template.
20+
* Role now runs correctly when using Ansible's check mode.
2021

2122
## 0.2.0 (September 24, 2020)
2223

handlers/main.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
---
22
- name: (Handler - NGINX Config) Check NGINX
33
command: nginx -t
4-
register: config
4+
register: config_check
55
ignore_errors: yes
6+
check_mode: no
67
changed_when: false
78
listen: (Handler - NGINX Config) Run NGINX
89

910
- name: (Handler - NGINX Config) Print NGINX error if syntax check fails
1011
debug:
11-
var: config.stderr_lines
12-
failed_when: config.rc != 0
13-
when: config.rc != 0
12+
var: config_check.stderr_lines
13+
failed_when: config_check.rc != 0
14+
when:
15+
- config_check.stderr_lines is defined
16+
- config_check.rc != 0
1417
listen: (Handler - NGINX Config) Run NGINX
1518

1619
- name: (Handler - NGINX Config) Start/reload NGINX

tasks/config/debug-output.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
---
22
- name: Register NGINX config
33
command: nginx -T
4+
ignore_errors: "{{ ansible_check_mode }}"
5+
check_mode: no
46
changed_when: false
5-
register: config
7+
register: config_full
68

79
- name: Print NGINX config
810
debug:
9-
var: config.stdout_lines
11+
var: config_full.stdout_lines
12+
when: config_full.stdout_lines is defined

0 commit comments

Comments
 (0)