1

I need to bring up the following service and configure recovery options as below using ansible,

rem Register windows services
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\installutil.exe" "C:\myservice.exe"

rem Configure windows services recovery options
%SystemRoot%\System32\sc.exe failure myservice reset= 600 actions= restart/300000
%SystemRoot%\System32\sc.exe failureflag myservice 1

I can use win_service module to install service.

- name: Install Windows service
  win_service:
    name: myservice
    path: 'C:\myservice.exe'

How do I set recovery options in ansible ? I don't see any free-form text in below given link, https://docs.ansible.com/ansible/2.3/win_service_module.html

user3362908
  • 381
  • 2
  • 12

1 Answers1

1

The link you have shared points out to the win_service module in ansible version 2.3 which is quite old.

Meanwhile, I just checked and there is nothing about recovery options either in the latest version of win_service (2.8 at time of writing)

However, there seems to be an ongoing pretty advanced PR that would introduce changes meeting your requirements. There are still some issues to fix and it missed 2.9 code freeze. But hopefully it could come out for the next version.

If you really can't wait you can try to install ansible from the above PR branch. But if you want to keep it safe, you will have to launch commands through the win_command module after installing the service until this PR is released.

Zeitounator
  • 18,663
  • 4
  • 26
  • 38