First, I check the list of windows process are running and collect the output into a register variable. next I need to start the service which are not running based on the above output(register).
- name: Check weather service is running or not
ansible.windows.win_service_info:
name: "{{ item }}"
register: win_service_info
with_items:
- BrokerInfrastructure #Background Tasks Infrastructure (BrokerInfrastructure) Service
- DcomLaunch #DCOM Server Process Launcher Service
- gpsvc #Group Policy Client Service
- name: run services
ansible.windows.win_service:
name: << don't know how to write >>
start_mode: auto
state: started
register: service_startup
with_items: "{{ win_service_info.results }}"
when: << i don't know how to write >>