summaryrefslogtreecommitdiff
path: root/lib/ansible/plugins/shell/powershell.py
Commit message (Collapse)AuthorAgeFilesLines
* improve become_method: runas error handling (#23328)Matt Davis2017-04-061-3/+27
| | | Prescriptive errors for username/password issues and NTLM/Kerb auth failures, cleans up exception noise.
* force Windows to always use preamble-free UTF8 input encoding (#22934)Matt Davis2017-03-241-0/+3
| | | | * fixes #15770 * When running under the UTF-8 codepage, Powershell subprocesses will fail (eg, Start-Job, others) if the input encoding is using the default BOM preamble. This fix forces it to use no preamble in leaf_exec and win_shell, and includes tests to verify that Start-Job works.
* fix Windows env handling (#22927)Matt Davis2017-03-231-3/+8
| | | | | * fixes #22441 * fixes #22655 * moves all env handling into the exec wrapper; this should work for everything but raw, which is consistent with non-Windows.
* Suppress Windows Add-Type debug noise (#22722)Matt Davis2017-03-161-2/+0
|
* make windows async ... async (#22624)Matt Davis2017-03-141-14/+69
| | | Fixes #22575 - issue under new exec wrapper where unconstrained handle inheritance (for stdin) caused WinRM to block on breakaway processes. Uses explicit handle inheritance to ensure that only stdin read handle gets inherited. Adds test to ensure that async is actually async.
* prevent winrm Add-Type debug noise from polluting stderr (#22583)Matt Davis2017-03-131-0/+2
|
* suppress PS "unapproved verb" warning (#22018)Matt Davis2017-02-271-4/+4
|
* Complete rewrite of Windows exec wrapper (#21510)Matt Davis2017-02-171-0/+857
| | | | | | | | * supports pipelining for faster execution * supports become (runas), creates interactive subsession under WinRM batch logon * supports usage of arbitrary module_utils files * modular exec wrapper payload supports easier extension * integrates async wrapper behavior for pipelined/become'd async * module_utils are loaded as true Powershell modules, no more runtime modifications to module code
* fix powershell mkdtempBrian Coca2017-01-251-2/+2
|
* Preserve exit code in winrm exec (#20166)Matt Davis2017-01-161-2/+6
| | | Raw winrm exec discards the exit code from external processes- this change preserves the exit code if present.
* Move uses of to_bytes, to_text, to_native to use the module_utils version ↵Toshio Kuratomi2016-09-061-6/+7
| | | | | | | | (#17423) We couldn't copy to_unicode, to_bytes, to_str into module_utils because of licensing. So once created it we had two sets of functions that did the same things but had different implementations. To remedy that, this change removes the ansible.utils.unicode versions of those functions.
* windows environment support (#17402)Matt Davis2016-09-061-2/+26
|
* Use file list, not recursion, in _fixup_perms. (#16924)Matt Clay2016-08-051-3/+3
| | | | | | | | | Run setfacl/chown/chmod on each temp dir and file. This fixes temp file permissions handling on platforms such as FreeBSD which always return success when using find -exec. This is done by eliminating the use of find when setting up temp files and directories. Additionally, tests that now pass on FreeBSD have been enabled for CI.
* Move binary module detection into executor/module_common.pyMatt Martz2016-05-121-1/+1
|
* Get binary modules working for windows, assuming .exe for windowsMatt Martz2016-05-121-3/+9
|
* skip fixup_perms for PowershellMatt Davis2016-04-071-1/+7
| | | | | | | action plugins will now skip _fixup_perms for Powershell. We'll have to come up with another way to do this at some point, but it's not necessary yet since we don't support become on Windows. Also added NotImplementedError throws to chmod/chown/set_facl operations on Powershell (instead of returning '') in case anyone tries to use them in the future. fixes #15312
* moved 'path exists' function to shellBrian Coca2016-03-251-0/+16
| | | | now it will work with powershell/winrm
* Merge pull request #14930 from ↵Matt Davis2016-03-251-1/+1
|\ | | | | | | | | mholiv/enable_dollar_as_first_char_in_folder_and_userName Modified files to use single quotes rather than double for file path.…
| * Modified files to use single quotes rather than double for file path. ↵root2016-03-111-1/+1
| | | | | | | | | | | | Powershell does not process $ variables in strings that are single quoted. Powershell DOES process $ variables that are in double quoted strings. Using single quotes enables ansible to handle file paths that contain folders that start with $. (i.e. C:/Users/$admin/...)
* | fix breakage from new recursive=True arg to chmodnitzmahone2016-03-241-1/+1
|/
* moved to base class for shell pluginsBrian Coca2016-02-091-2/+0
| | | | | | | fish now sets env vars correctly fish checksum now works fixed and cleaned up imports fixed typo
* Establish sh as the default shell plugin.Toshio Kuratomi2016-02-021-0/+7
| | | | This is a fix for one of the problems pointed out in #14176
* Revert "Make sudo+requiretty and ANSIBLE_PIPELINING work together"Toshio Kuratomi2015-12-031-1/+1
| | | | | | This reverts commit f488de85997079f480d504f73537e3e33ff2495b. Reverting for now due to hard to pin down bugs: #13410 #13411
* allow shell plugin to affect remote module filenamenitzmahone2015-12-011-0/+7
| | | | Fix for 13368, added get_remote_filename to shell plugins, powershell version appends .ps1 if necessary, base shell plugin no-ops
* Make sudo+requiretty and ANSIBLE_PIPELINING work togetherAbhijit Menon-Sen2015-12-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Pipelining is a *significant* performance benefit, because each task can be completed with a single SSH connection (vs. one ssh connection at the start to mkdir, plus one sftp and one ssh per task). Pipelining is disabled by default in Ansible because it conflicts with the use of sudo if 'Defaults requiretty' is set in /etc/sudoers (as it is on Red Hat) and su (which always requires a tty). We can (and already do) make sudo/su happy by using "ssh -t" to allocate a tty, but then the python interpreter goes into interactive mode and is unhappy with module source being written to its stdin, per the following comment from connections/ssh.py: # we can only use tty when we are not pipelining the modules. # piping data into /usr/bin/python inside a tty automatically # invokes the python interactive-mode but the modules are not # compatible with the interactive-mode ("unexpected indent" # mainly because of empty lines) Instead of the (current) drastic solution of turning off pipelining when we use a tty, we can instead use a tty but suppress the behaviour of the Python interpreter to switch to interactive mode. The easiest way to do this is to make its stdin *not* be a tty, e.g. with cat|python. This works, but there's a problem: ssh will ignore -t if its input isn't really a tty. So we could open a pseudo-tty and use that as ssh's stdin, but if we then write Python source into it, it's all echoed back to us (because we're a tty). So we have to use -tt to force tty allocation; in that case, however, ssh puts the tty into "raw" mode (~ICANON), so there is no good way for the process on the other end to detect EOF on stdin. So if we do: echo -e "print('hello world')\n"|ssh -tt someho.st "cat|python" …it hangs forever, because cat keeps on reading input even after we've closed our pipe into ssh's stdin. We can get around this by writing a special __EOF__ marker after writing in_data, and doing this: echo -e "print('hello world')\n__EOF__\n"|ssh -tt someho.st "sed -ne '/__EOF__/q' -e p|python" This works fine, but in fact I use a clever python one-liner by mgedmin to achieve the same effect without depending on sed (at the expense of a much longer command line, alas; Python really isn't one-liner-friendly). We also enable pipelining by default as a consequence.
* FIx typo arg_path (not plural)Toshio Kuratomi2015-10-021-1/+1
|
* Also add args_path param to powershell shell pluginJames Cammarata2015-10-021-1/+1
|
* Add PowerShell exception handling and turn on strict mode.Chris Church2015-09-151-7/+38
| | | | | | | | * Add exception handling when running PowerShell modules to provide exception message and stack trace. * Enable strict mode for all PowerShell modules and internal commands. * Update common PowerShell code to fix strict mode errors. * Fix an issue with Set-Attr where it would not replace an existing property if already set. * Add tests for exception handling using modified win_ping modules.
* Revert "Add PowerShell exception handling and turn on strict mode."revert-12047-powershell_common_cleanupJames Cammarata2015-08-231-38/+7
|
* Add PowerShell exception handling and turn on strict mode.Chris Church2015-08-221-7/+38
| | | | | | | | * Add exception handling when running PowerShell modules to provide exception message and stack trace. * Enable strict mode for all PowerShell modules and internal commands. * Update common PowerShell code to fix strict mode errors. * Fix an issue with Set-Attr where it would not replace an existing property if already set. * Add tests for exception handling using modified win_ping modules.
* Fix for PowerShell unquote method when passed None.Chris Church2015-08-021-0/+1
|
* Fixes for WinRM/PowerShell support in v2.Chris Church2015-07-311-19/+46
| | | | | | | | | | | | | | | | | | | | | | | | - Add support for inserting module args into PowerShell modules. Fixes #11661. - Support Windows paths containing spaces. Applies changes from #10727 to v2. Fixes #9999. Should also fix ansible/ansible-modules-core#944 and ansible/ansible-modules-core#1007. - Change how execution policy is set for running remote scripts. Applies changes from #11092 to v2. Also fixes ansible/ansible-modules-core#1776. - Use codepage 65001 (UTF-8) for WinRM connection instead of default (CP437), convert command to UTF-8 and results from UTF-8. Replaces changes from #10024. Fixes #11198. - Close WinRM connection when task completes. - Use win_stat, win_file and win_copy modules instead of stat, file and copy when called from within other action plugins (only when using WinRM+PowerShell). - Unquote Windows path arguments before passing to win_stat, win_file, win_copy and slurp modules (only when using WinRM/PowerShell). - Check for win_ping module to determine if core modules are missing (only when using WinRM/PowerShell). - Add stdout_lines to result from running low level commands (so stdout_lines is available when using raw/script). - Update copy action plugin to use shell functions for joining paths and checking for trailing slash. - Update fetch action plugin to unquote source path when using Windows paths. - Add win_copy and win_template action plugins that inherit from copy and template. - Support running .bat and .cmd scripts using default system encoding instead of UTF-8. - Always send PowerShell commands as base64-encoded blobs to allow for running simple PowerShell commands via raw. - Support running modules on Windows with interpreters other than PowerShell. - Update integration tests to support above changes and test unicode fixes. - Add test for win_user error from ansible/ansible-modules-core#1241 (fixed by ansible/ansible-modules-core#1774). - Add test for additional win_stat output values (implemented by ansible/ansible-modules-core#1473). - Add test for OS architecture and name from setup.ps1 (implemented by ansible/ansible-modules-core#1100). All WinRM integration tests pass for me with these changes.
* Winrm fixes for develJames Cammarata2015-06-291-2/+14
| | | | | * Include fixes for winrm connection plugin from v1 code * Fixing shell plugin use
* Making the switch to v2James Cammarata2015-05-031-0/+120