diff --git a/handlers/main.yml b/handlers/main.yml index 92971d2..6f8e638 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,3 +1,7 @@ --- - name: restart nginx service: name=nginx state=restarted + +- name: validate nginx configuration + command: nginx -t -c /etc/nginx.conf + changed_when: False diff --git a/tasks/vhosts.yml b/tasks/vhosts.yml index 621ab6b..9cee3d3 100644 --- a/tasks/vhosts.yml +++ b/tasks/vhosts.yml @@ -12,11 +12,16 @@ dest: "{{ nginx_vhost_path }}/vhosts.conf" mode: 0644 when: nginx_vhosts|length > 0 - notify: restart nginx + notify: + - validate nginx configuration + - restart nginx - name: Remove managed vhost config file (if no vhosts are configured). file: path: "{{ nginx_vhost_path }}/vhosts.conf" state: absent when: nginx_vhosts|length == 0 - notify: restart nginx + notify: + - validate nginx configuration + - restart nginx +