--- - name: Check nginx config for errors shell: nginx -t changed_when: True listen: "Restart nginx" - name: "[OpenRC] Restart service: nginx (to deploy config changes)" service: name: nginx state: restarted when: - ansible_service_mgr == "openrc" listen: "Restart nginx" - name: "[systemd] Restart service: nginx (to deploy config changes)" systemd: name: nginx state: restarted when: - ansible_service_mgr == "systemd" listen: "Restart nginx"