--- - name: Restart nginx with config check debug: msg="checking nginx config before restart" changed_when: True notify: - Check nginx configuration - Restart nginx - name: Reload nginx with config check debug: msg="checking nginx config before reload" changed_when: True notify: - Check nginx configuration - Reload nginx - name: Check nginx configuration command: "nginx -t" register: result changed_when: "result.rc != 0" check_mode: no - name: Restart nginx service: name=nginx state=restarted - name: Reload nginx service: name=nginx state=reloaded # vim:ft=ansible