Windows service recovery on failure with ansible?

40 views
Skip to first unread message

vinod devops

unread,
May 7, 2020, 3:42:45 PM5/7/20
to Ansible Project
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

J Hawkesworth

unread,
May 7, 2020, 4:15:18 PM5/7/20
to Ansible Project
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

Jordan Borean

unread,
May 7, 2020, 10:18:52 PM5/7/20
to Ansible Project
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

vinod devops

unread,
May 8, 2020, 3:36:50 PM5/8/20
to Ansible Project
Thank you so much Hawkesworth

vinod devops

unread,
May 8, 2020, 3:37:58 PM5/8/20
to Ansible Project
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?
Reply all
Reply to author
Forward
0 new messages