# Windows service recovery on failure with ansible?

**URL:** <https://forum.ansible.com/t/windows-service-recovery-on-failure-with-ansible/32880>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [May 7, 2020, 7:42pm UTC](https://forum.ansible.com/t/windows-service-recovery-on-failure-with-ansible/32880 "2020-05-07T19:42:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vinod\_devops](https://avatars.discourse-cdn.com/v4/letter/v/41988e/32.png) [@vinod\_devops](https://forum.ansible.com/u/vinod_devops)\
**Post date:** [May 7, 2020, 7:42pm UTC](https://forum.ansible.com/t/windows-service-recovery-on-failure-with-ansible/32880/1 "2020-05-07T19:42:45Z")

</div>

Hi Friends,

How do I set windows service recovery on. failure,

suppose x service stopped due to failure, it needs to started automatically by creating recovery condition with. ansible windows service?

How do I do that ?

Thanks  
vinod

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [May 7, 2020, 8:15pm UTC](https://forum.ansible.com/t/windows-service-recovery-on-failure-with-ansible/32880/2 "2020-05-07T20:15:17Z")

</div>

I thought someone had added recovery actions to win\_service module, but maybe that PR never got finished, or I am confused with dependent services.

I think you would have to use script module and some powershell to set recovery actions. You could maybe use sc.exe too if you are in a hurry, although it would repeat the command every time you run the playbook. Maybe that doesn’t matter though, it depends on what you need to get done.

Hope this helps,

Jon

---

<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:** [May 8, 2020, 2:18am UTC](https://forum.ansible.com/t/windows-service-recovery-on-failure-with-ansible/32880/3 "2020-05-08T02:18:52Z")

</div>

It was added witht he PR [https://github.com/ansible-collections/ansible.windows/pull/40](https://github.com/ansible-collections/ansible.windows/pull/40) which is the ‘win\_service’ module in the ansible.windows collection. This collection is officially meant to be the source of supported Windows module in Ansible 2.10 and onwards but you might be able to use it for Ansible 2.9.

Thanks

Jordan

---

<div class="post-metadata">

**Author:** ![vinod\_devops](https://avatars.discourse-cdn.com/v4/letter/v/41988e/32.png) [@vinod\_devops](https://forum.ansible.com/u/vinod_devops)\
**Post date:** [May 8, 2020, 7:36pm UTC](https://forum.ansible.com/t/windows-service-recovery-on-failure-with-ansible/32880/4 "2020-05-08T19:36:50Z")

</div>

Thank you so much Hawkesworth

---

<div class="post-metadata">

**Author:** ![vinod\_devops](https://avatars.discourse-cdn.com/v4/letter/v/41988e/32.png) [@vinod\_devops](https://forum.ansible.com/u/vinod_devops)\
**Post date:** [May 8, 2020, 7:37pm UTC](https://forum.ansible.com/t/windows-service-recovery-on-failure-with-ansible/32880/5 "2020-05-08T19:37:57Z")

</div>

Thank you so much Jordan,

I found these options,

- error\_control
- failure\_actions
- failure\_actions\_on\_non\_crash\_failure
- failure\_command
- failure\_reboot\_msg
- failure\_reset\_period\_sec
- load\_order\_group
- pre\_shutdown\_timeout\_ms
- required\_privileges
- service\_type
- sid\_info  
I want to use failure\_actions , what values should I pass?
