Ansible in a Minute · Certified Collections ·
Ensure a Windows service is started
Short answer
Use ansible.windows to make sure a Windows service is running and set to automatic start.
Request
ensure the Spooler Windows service is started with start mode auto
Example
A quick heads-up: Every environment is different. Review and test this example before you run it on systems you care about.
YAML
---
- name: Ensure a Windows service is started
hosts: windows
gather_facts: false
tasks:
- name: Ensure Print Spooler is running
ansible.windows.win_service:
name: Spooler
state: started
start_mode: autoHow it works
win_service sets the desired service state on Windows hosts. state started starts the service when it is stopped. start_mode auto sets the service to start at boot.
When to use it
- Enforcing required Windows services after patching
- Standardizing start mode for shared application services
Requirements
- Collection: ansible.windows
- Technology: Windows
- ansible.windows collection installed
- Windows hosts reachable with WinRM or another supported connection
Validation
- Syntax validated
- Not execution-tested
- Last verified 2026-09-09
Notes
Replace Spooler with the service name your environment requires. Confirm the service exists before you enforce start mode in production.
Try it with BacklogZero
Ask BacklogZero to generate this automation for your environment.