ansible-role-nginx/handlers/main.yml
2021-03-22 18:44:21 +01:00

42 lines
902 B
YAML

---
- 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) Check NGINX
command: nginx -t
args:
chdir: /etc/nginx/
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_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
service:
name: amplify-agent
state: started
- name: (Handler) Run logrotate
command: logrotate -f /etc/logrotate.d/nginx