Thanks, Matt.

What I ended up doing was using NSSM and installing them both as services. 
That seems to be working well for at least one of them thus far.

Looking forward to async support in 2.2, though. 

Allen

On Wednesday, August 10, 2016 at 6:05:04 PM UTC-5, Matt Davis wrote:
>
> You're partially right: it's not Ansible, but WinRM that's killing the 
> process.
>
> WinRM runs everything under a Windows job object, and that job object gets 
> terminated when the connection is closed (ie, when Ansible finishes that 
> task), which causes all processes spawned under it to be terminated as well.
>
> Ansible 2.2 is scheduled to ship with Windows async support, as well as 
> the win_command/win_shell modules, which currently support a "breakaway" 
> parameter to allow you to do exactly what you're trying to do here (spawn a 
> process that will run longer than the Ansible WinRM session by explicitly 
> breaking away from WinRM's job object). 
>
> If you need to do it sooner than that, you might want to look into the 
> win_scheduled_task module, which allows you to run commands/scripts outside 
> the constraints of WinRM.
>
> -Matt
>
> On Wednesday, August 10, 2016 at 2:22:18 PM UTC-7, Allen Fisher wrote:
>>
>> Hello All--
>>
>> I'm trying to get a couple of jars up and running in the background on 
>> some Windows machines. My expected result is at the end of the play I have 
>> both jars running with logs for both, and they're listening on ports 4444 
>> and 24240 respectively. Here's my tasks:
>>
>> - raw: Start-Process javaw -ArgumentList '-jar 
>> C:\Users\Administrator\mySweetJar.jar'
>> - raw: Start-Process javaw -ArgumentList 
>> '-Dwebdriver.chrome.driver=C:\Windows\System32\chromedriver.exe 
>> -jar C:\selenium.jar -browserSessionReuse -browserTimeout 300 -timeout 
>> 300000 -maxSession 1 -log C:\Users\Administrator\node.log'
>>
>> What actually happens is that Ansible reports the commands running 
>> successfully:
>>
>> TASK [Starting MySweetJar...] 
>> ****************************************************
>> task path: /Users/allen.fisher/projects/setup-windows-SUT/playbook.yml:61
>> <XX.XX.XX.XX> ESTABLISH WINRM CONNECTION FOR USER: administrator on PORT 
>> 5985 TO XX.XX.XX.XX
>> <XX.XX.XX.XX> EXEC Start-Process javaw -ArgumentList '-jar 
>> C:\Users\Administrator\MySweetJar.jar'
>> ok: [XX.XX.XX.XX] => {"changed": false, "invocation": {"module_args": {
>> "_raw_params": "Start-Process javaw -ArgumentList '-jar 
>> C:\\Users\\Administrator\\MySweetJar.jar'"}, "module_name": "raw"}, "rc": 
>> 0, "stderr": "", "stdout": "", "stdout_lines": []}
>>
>> TASK [Starting Selenium...] 
>> ****************************************************
>> task path: /Users/allen.fisher/projects/setup-windows-SUT/playbook.yml:63
>> <XX.XX.XX.XX> ESTABLISH WINRM CONNECTION FOR USER: administrator on PORT 
>> 5985 TO XX.XX.XX.XX
>> <XX.XX.XX.XX> EXEC Start-Process javaw -ArgumentList 
>> '-Dwebdriver.chrome.driver=C:\Windows\System32\chromedriver.exe 
>> -jar C:\selenium.jar -browserSessionReuse -browserTimeout 300 -timeout 
>> 300000 -maxSession 1 -log C:\Users\Administrator\node.log'
>> ok: [XX.XX.XX.XX] => {"changed": false, "invocation": {"module_args": {
>> "_raw_params": "Start-Process javaw -ArgumentList 
>> '-Dwebdriver.chrome.driver=C:\\Windows\\System32\\chromedriver.exe -jar 
>> C:\\selenium.jar -browserSessionReuse -browserTimeout 300 -timeout 300000 
>> -maxSession 1 -log C:\\Users\\Administrator\\node.log'"}, "module_name": 
>> "raw"}, "rc": 0, "stderr": "", "stdout": "", "stdout_lines": []}
>>
>> But the ports are not open, and there are no logs so it's almost like 
>> Ansible is killing the process before it even gets going.
>>
>> The commands run as I would expect on the box directly. I've tried 
>> bundling them into a PowerShell script and using the script module to 
>> execute the commands, I've tried both java.exe and javaw.exe with no 
>> success. Does anyone have a way to accomplish what I'm after?
>>
>> Thanks, Allen
>>
>

-- 
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/84f1fd81-5613-4751-9e7d-3222ca1ae5d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to