ansible-role-nginx/handlers/main.yml
Alessandro Fael Garcia 8b41c27cb5
Improve the error formatting when there's a syntax error (#324)
And remove the debug tasks messages.
2020-09-18 19:51:50 +02:00

48 lines
1.0 KiB
YAML

---
- name: "(Handler) Check NGINX"
command: "nginx -t"
register: config
ignore_errors: yes
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
listen: "(Handler) Run NGINX"
- name: "(Handler) Systemd daemon-reload"
systemd:
daemon_reload: yes
- name: "(Handler) Start/Reload NGINX"
service:
name: nginx
state: reloaded
enabled: yes
when:
- nginx_start | bool
- not ansible_check_mode | bool
listen: "(Handler) Run NGINX"
- name: "(Handler) Start NGINX Amplify agent"
service:
name: amplify-agent
state: started
- name: "(DEPRECATED Handler: Debian/Ubuntu/CentOS/RedHat) Start NGINX Unit"
service:
name: unit
state: started
enabled: yes
- name: "(DEPRECATED Handler: FreeBSD) Start NGINX Unit"
service:
name: unitd
state: started
enabled: yes
- name: "(Handler) Run logrotate"
command: logrotate -f /etc/logrotate.d/nginx