New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
win_shell / win_command task stuck on execution from 2.5.1 onwards #44905
Comments
Files identified in the description: If these files are inaccurate, please update the |
Files identified in the description: If these files are inaccurate, please update the |
While I know you said running it with win_command is the same, you shouldn't be using win_shell to run an executable as you could be coming across escaping issues. The args you have are relatively tame so I doubt that is the issue but just an FYI. As for why this is happening IIRC we changed win_shell and win_command to use the raw CreateProcessW call and bypassed If it is working on 2.5.0 and not 2.5.1+ then I'm not entirely sure what the problem could be. Are you running the task with become or anything custom? |
Thanks for tip about win_command vs win_shell. I recall seeing it as well on the lint rule ANSIBLE0013 but I now notice it's not capturing the win_shell, only shell. I just tried to execute win_command with become: false on 2.6.3 to ensure I am not using privilege elevation but the outcome is the same and I don't think I'm using anything custom... |
@madrover are you able to 100% confirm whether 2.5.0 works and the issue starts with 2.5.1? You are saying the process is no longer running on the remote host. This is what a running process looks like from Ansible (using procexp to get the process hierarchy) If you have a What happens if you run this with the raw task? |
Same result on macOS High Sierra (10.13.6) and Ansible >= 2.5.1 (Ansible 2.5.0 works Ok), when testing the same scripts that @madrover is testing. |
@madrover so this shows the rhapsody installer is still running in the background and because that hasn't closed Ansible hasn't returned back from the task. Is that screenshot from a raw task or win_shell/win_command? We need to figure out why this is happening. Is this a public executable I can download and test with. I'm struggling to understand why 2.5.0 works but a dot release (which only contains bugfixes) does not. Even looking at the git history there's nothing I can see that may have caused this. |
The raw module still runs under winrshost.exe and is a bit more direct than win_shell/win_command which is run under a few more layers controlled by Ansible. Is this an installer that is available online that I can play around with? |
This installer is not commonly available online. I might be able to share with you but I need to check on my company beforehand, I'll keep you posted. |
@madrover you can try and run things locally and see how it works, what you would need to do is;
It would be good to know;
|
Ok so that’s a good sign that the win_shell/win_command modules are fine as they do exactly what you are running locally. The next thing to rule out is running the code from a Runspace and seeing if that works. This is a bit trickier and I’ll see if I can give you a decent set of instructions tomorrow morning (~9 hours). This could account for raw working compared to a module as raw doesn’t run in our normal wrapper. |
Ok so here's how you can run the same code in a Runspace.
Let me know if that works or not. |
I just ran the code you shared with some minor tweaks to add absolute paths to the files and the output has been:
The installer has finished successfully and the installed service is running. On a related note, I'm liaising with my company so I can share the installer with you to perform some testing but I'm still waiting for the approval... |
@jborean93, I've contacted you privately to provide the installer we're using and do further testing. |
@madrover I've figured out the issue, we changed the behaviour of The trouble in your scenario is that the I'm toying around with the idea of controlling the CREATE_NEW_CONSOLE flag for win_command and win_shell. This won't help you in the short term as it would only be available in 2.8. To get you going I recommend you use async to run this as it effectively escapes the WinRM booundary. You can simply get this working by adding |
One thing I should mention, if you have control over the installer, it may be better to have that create the monitor process with the CREATE_NEW_CONSOLE flag and not be reliant on Ansible’s internal processes. I’m going to post the question as to whether we expose the flag field in the command/shell modules at the next working group. Personally the more I think about it the more I think async is the right choice for this issue. |
Awesome, @jborean93! Unfortunately, I don't have much control about the installer, so modifying the process creation flag would be a complex endeavour. On the other hand, I have modified the task call to:
and now the task is happily continuing :) Many thanks for that! This ticket can be closed, unless further discussion of the CREATE_NEW_CONSOLE flag needs to be discussed. |
@madrover thanks for the confirmation, glad you've got it working. I've posted a question to see if we want to expose the flag in win_command/win_shell ansible/community#294 (comment). Will close that based on whatever is decided there. |
At the latest WWG we decided not to go ahead with this feature as async can achieve the same result and the differences between winrm and psrp makes it hard to reconcile the console options. |
SUMMARY
win_shell task gets stuck on execution since version 2.5.1. Same exact task works on previous versions such as 2.4.3 and 2.5.0.
Same behaviors appears with win_command
ISSUE TYPE
COMPONENT NAME
win_shell
win_command
ANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT
OSX as control host, Windows as managed host
STEPS TO REPRODUCE
The task definition is:
EXPECTED RESULTS
Executing the task up to 2.5.0 the installer executes via win_shell finished and the playbook continues.
ACTUAL RESULTS
Executing the same task since 2.5.1 up until 2.6.3, the task gets stuck:
and nothing more is shown. We can see on the managed server that the installer has finished.
The text was updated successfully, but these errors were encountered: