Awesome, thanks for the brief explanation. So correct me if I'm wrong, func exec_command is the one which does the pipeliinig execution , which is then accepted by $input via and then call execwrapper scriptblock ?
On Friday, August 16, 2019 at 2:40:57 AM UTC+5:30, Jordan Borean wrote: > > Hi > > This particular script is part of the put_file operation for winrm [1] > which is executed like "PowerShell.exe .... -EncodedCommand ScriptB64". > Part of the put_file method is to read the bytes of the file to transfer > across and send it over the stdin pipe of the process under the WSMan Send > operation. There is an automatic trigger in PowerShell where the begin > block runs then the process block will run for each input that is sent > until we tell it there is no more until finally the end block runs. The > '$input' variable is an automatic variable which contains the input from > the stdin pipe for that process (each byte fragment of the file). > > In saying all this, the put_file operation should not be running at all > for standard module execution. We use pipelining in pretty much all cases > to execute a module and the only times put_file is used are; > > - An action plugin on the controller needs to put a file for a module > to use, e.g. win_copy, win_template, script > - The ANSIBLE_KEEP_REMOTE_FILES=1 env var is set when running Ansible, > this should only be used for debugging purposes and is not the standard > operation > > What normally happens in the pipelining scenario is that we run the > bootstrap_wrapper.ps1 [2] which takes in data from the stdin pipe to > execute. This data is a string split by null chars where the first part is > the exec_wrapper and the second part is the module manifest info which > drives the wrapper. This way no data touches the disk (unless we need to > copy a file) making things a lot faster than before. > > [1] - > https://github.com/ansible/ansible/blob/491a47c7c5be8ba5b4cca4e1a5171c15d669a47f/lib/ansible/plugins/connection/winrm.py#L565 > [2] - > https://github.com/ansible/ansible/blob/devel/lib/ansible/executor/powershell/bootstrap_wrapper.ps1 > > Thanks > > Jordan > -- You received this message because you are subscribed to the Google Groups "Ansible Development" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-devel/2be16fca-3458-464f-abb6-3cd7551ee58d%40googlegroups.com.
