# (Windows) Service Fails to Stop in Actual Play - But Actually Stops On Test Server

**URL:** <https://forum.ansible.com/t/windows-service-fails-to-stop-in-actual-play-but-actually-stops-on-test-server/26334>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [December 19, 2017, 8:45pm UTC](https://forum.ansible.com/t/windows-service-fails-to-stop-in-actual-play-but-actually-stops-on-test-server/26334 "2017-12-19T20:45:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Heather\_Luna](https://avatars.discourse-cdn.com/v4/letter/h/5e9695/32.png) [@Heather\_Luna](https://forum.ansible.com/u/Heather_Luna)\
**Post date:** [December 19, 2017, 8:45pm UTC](https://forum.ansible.com/t/windows-service-fails-to-stop-in-actual-play-but-actually-stops-on-test-server/26334/1 "2017-12-19T20:45:57Z")

</div>

Weird thing happening with my Windows Playbook for Splunk.

I run the play which includes stopping the Splunk Service. When it gets to the Splunk Service part with the service is supposed to stop, it seemingly fails. Now I checked before I ran the play and the Splunk service was running on my test box, and although the play fails, it’s in a stopped status after the play runs.

TASK [Stopping Splunkd Service in Preperation for Splunk Directory Removal] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [computername]: FAILED! =\> {“can\_pause\_and\_continue”: false, “changed”: false, “depended\_by”: , “dependencies”: , “description”: “Splunkd is the indexing and searching engine for Splunk, a data platform for operational intelligence. It is required for Splunk instances acting as an indexer. If it is stopped, Splunk will not process data and will be unavailable for search. Splunkweb depends on Splunkd. Please see [www.splunk.com](http://www.splunk.com) for more information. Questions can be submitted to [www.splunk.com/answers](http://www.splunk.com/answers) or for supported customers [www.splunk.com/page/submit\_issue](http://www.splunk.com/page/submit_issue)”, “desktop\_interact”: false, “display\_name”: “Splunkd Service”, “exists”: true, “msg”: “Service ‘Splunkd Service (Splunkd)’ cannot be stopped due to the following error: Cannot stop Splunkd service on computer ‘.’.”, “name”: “Splunkd”, “path”: “"C:\Program Files\Splunk\bin\splunkd.exe" service”, “start\_mode”: “auto”, “state”: “running”, “username”: “LocalSystem”}

---

<div class="post-metadata">

**Author:** ![Heather\_Luna](https://avatars.discourse-cdn.com/v4/letter/h/5e9695/32.png) [@Heather\_Luna](https://forum.ansible.com/u/Heather_Luna)\
**Post date:** [December 20, 2017, 12:44am UTC](https://forum.ansible.com/t/windows-service-fails-to-stop-in-actual-play-but-actually-stops-on-test-server/26334/2 "2017-12-20T00:44:38Z")

</div>

**UPDATE** - I reverted back to an older snapshot of the test box but that leads me to other questions about how to handle tasks when they’re not completed in a timely Ansible time. I was looking into the async piece where you can set a polling interval and such, [http://docs.ansible.com/ansible/latest/playbooks\_async.html](http://docs.ansible.com/ansible/latest/playbooks_async.html) when I asked my boss about it he said that this would be his last effort - is this not the proper way to handle situations like this where tasks fail for taking too long? I’m new so I don’t know 🙂

When I leverage this playbook against 60+ hosts I’m not going to be able to manually troubleshoot ones that are taking a long time because x y z.

---

<div class="post-metadata">

**Author:** ![jborean](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jborean/32/1525_2.png) [@jborean](https://forum.ansible.com/u/jborean)\
**Post date:** [December 20, 2017, 3:49am UTC](https://forum.ansible.com/t/windows-service-fails-to-stop-in-actual-play-but-actually-stops-on-test-server/26334/3 "2017-12-20T03:49:31Z")

</div>

Ansible is a declarative language where you put the state of a resource, in this case you want a service to be stopped. If you were to run it again then it would just try to set the service to stopped or skip the task if it is already stopped.

This situation is a bit more difficult as Ansible is failing to stop the service for some reason, most likely the service is in use and is refusing to stop at that current point in time. You would need to look into the logs to find out why it didn’t stop when Ansible asked it to.

Thanks

Jordan

---

<div class="post-metadata">

**Author:** ![Heather\_Luna](https://avatars.discourse-cdn.com/v4/letter/h/5e9695/32.png) [@Heather\_Luna](https://forum.ansible.com/u/Heather_Luna)\
**Post date:** [December 20, 2017, 4:13am UTC](https://forum.ansible.com/t/windows-service-fails-to-stop-in-actual-play-but-actually-stops-on-test-server/26334/4 "2017-12-20T04:13:33Z")

</div>

Thanks Jordan! (Again ;))

Are you talking about a specific Ansible log or just generic Windows system logs?

Heather

---

<div class="post-metadata">

**Author:** ![jborean](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jborean/32/1525_2.png) [@jborean](https://forum.ansible.com/u/jborean)\
**Post date:** [December 20, 2017, 4:44am UTC](https://forum.ansible.com/t/windows-service-fails-to-stop-in-actual-play-but-actually-stops-on-test-server/26334/5 "2017-12-20T04:44:42Z")

</div>

The Windows Event Log, I believe the service information is stored in either the System or Application event log and usually gives you more details as to why a service started or failed to stop. Unfortunately Ansible is limited to what info Powershell returns which in this case was “Cannot stop Splunkd service on computer ‘.’.” which is really not helpful at all.
