---
- name: Windows validate service | Get service info
  win_service:
    name: "{{ service_name }}"
  register: service_stat

- name: Windows validate service | Fail if the service doesn't exist
  fail:
    msg: "The service {{ service_name }} doesn't exist"
  when: not service_stat.exists

- name: Windows validate service | Fail if the service is not running
  fail:
    msg: "The service {{ service_name }} is not running. Current state: {{ service_stat.state }}"
  when: service_stat.state != "running"

- name: Windows validate service | Fail if the service start mode is not auto (starts at boot time)
  fail:
    msg: "The service {{ service_name }} start mode is not auto (starts at boot time). Current start mode: {{ service_stat.start_mode }}"
  when: service_stat.start_mode != "auto"
