Windows service recovery on failure with ansible?

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

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

It was added witht he PR 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

Thank you so much Hawkesworth

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?