I am trying to provision windows server 2012 R2 machine with ansible and
for that i need to gather some custom facts about the running services. I
tried getting the information via the win_service module like this:
---
- hosts: windows
tasks:
- name: check services
win_service:
name: test1
register: result
ignore_errors: yes
- debug: msg="{{result}}"
- debug: msg="service is running"
when: result.state == 'running'
This works fine if the service exists but in case the service does not
exist, i get ugly looking failed message in the win_service task and as
there is no common member name in the registered variable 'result', i am
not sure how to first check if the service really exist and then proceed to
do something further. Is there a better way to check if service exists and
if yes, what is its state ?
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/a84074f4-3323-4a39-b844-abd70c563643%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.