[ansible-project] Re: Check existence and state of a service on windows machine using win_service

2019-03-18 Thread CORLEONE##
On Thursday, March 17, 2016 at 4:54:59 PM UTC+5:30, ishan jain wrote: > > Both get-service and sc.exe returns textual results. I will have to match > strings to check if service exists and its state and i never like to base > my conditions on pattern matching. > The best solution i could thing

[ansible-project] Re: Check existence and state of a service on windows machine using win_service

2016-03-20 Thread ishan jain
Agreed with your point - we should drag the machine in the state we want. But in my case the number 1 priority is to make the script idempotent, which seems like quite a thing on windows end. I not installing anything on the windows end and my application will run as standalone service, no inst

[ansible-project] Re: Check existence and state of a service on windows machine using win_service

2016-03-19 Thread 'J Hawkesworth' via Ansible Project
You could run a raw powershell command like Get-Service nameOfService -ErrorAction SilentlyContinue and then register the result, then check You would need the '-ErrorAction SilentlyContinue' bit otherwise when the service doesn't exist, Get-Service will fail. also if you prefer you could do

[ansible-project] Re: Check existence and state of a service on windows machine using win_service

2016-03-18 Thread 'J Hawkesworth' via Ansible Project
I suggest you add a task, before your win_service task that installs the service if it is not yet installed. Depending on what the service is, you might be able to use win_package to install it. If it is already installed, there is not much to loose by running the win_package task a second ti

[ansible-project] Re: Check existence and state of a service on windows machine using win_service

2016-03-18 Thread ishan jain
Both get-service and sc.exe returns textual results. I will have to match strings to check if service exists and its state and i never like to base my conditions on pattern matching. The best solution i could thing of is to go with win_service and define a failed_when situation along with. At l