ansible/ansible — pull request #9613 by mchw (2014-11-24 23:59:39+00:00)
Title: Windows powershell encoding fix for python 2.6.

This commit fixes ansible/ansible#8588 's root cause.

Additionally, it reverts @cchurch 's commit 57dee4545b3c34d1e66943def8d5e45ee95d66bd which is no longer needed to solve this issue (it doesn't hurt either).

Bug scenario:
* The try/catch mechanism doesn't work if no special characters are present in a command (it assumes unicode whereas utf-8 was given).
* This leads to task.module_name to be of type unicode.
* The module_name is part of the command string.
* The command string is then processed by powershell.py.
* powershell.py uses shlex to parse the command but the shlex doc for python 2.6 states that "The shlex module currently does not support Unicode input."
* This leads to a base64encoded string which contains a lot of zeroes and is quite long (like this in b64: ...AAAAAAAAAEEAAAAAAAAAcAAAAAAAAABwAAAAAAAAAEQAAA...).
* Powershell fails to handle this broken base64 string, saying it cannot find a file 'C' (which is the drive letter, rest of command is cut off).
* Symptoms: Running any of the win_* modules, the following message is shown (using -vvvv debug level)
WINRM RESULT
failed: [logonebm6-int] => {"failed": true, "parsed": false}
invalid output was: Processing -File 'C' failed because the file does not have a '.ps1' extension. Specify a valid Windows PowerShell script file name, and then try again.
FATAL: all hosts have already failed -- aborting