--- - name: restart nginx debug: msg="checking config first" changed_when: True notify: - check nginx configuration - restart nginx - after config check - name: reload nginx debug: msg="checking config first" changed_when: True notify: - check nginx configuration - reload nginx - after config check - name: check nginx configuration shell: "{{ nginx_binary_name }} -t" register: result changed_when: "result.rc != 0" always_run: yes when: nginx_installation_type in nginx_installation_types_using_service - name: restart nginx - after config check service: name={{ nginx_service_name }} state=restarted when: nginx_installation_type in nginx_installation_types_using_service and nginx_daemon_mode == "on" - name: reload nginx - after config check service: name={{ nginx_service_name }} state=reloaded when: nginx_installation_type in nginx_installation_types_using_service and nginx_daemon_mode == "on"