mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-02 14:40:19 -07:00
Add support for Windows hosts in the SSH connection plugin (#47732)
* Add support for Windows hosts in the SSH connection plugin * fix Python 2.6 unit test and sanity issues * fix up connection tests in CI, disable SCP for now * ensure we don't pollute the existing environment during the test * Add connection_windows_ssh to classifier * use test dir for inventory file * Required powershell as default shell and fix tests * Remove exlicit become_methods on connection * clarify console encoding comment * ignore recent SCP errors in integration tests * Add cmd shell type and added more tests * Fix some doc issues * revises windows faq * add anchors for windows links * revises windows setup page * Update changelogs/fragments/windows-ssh.yaml Co-Authored-By: jborean93 <jborean93@gmail.com>
This commit is contained in:
parent
cdf475e830
commit
8ef2e6da05
24 changed files with 657 additions and 143 deletions
|
@ -461,7 +461,7 @@ class ActionBase(with_metaclass(ABCMeta, object)):
|
|||
if remote_user is None:
|
||||
remote_user = self._get_remote_user()
|
||||
|
||||
if self._connection._shell.SHELL_FAMILY == 'powershell':
|
||||
if getattr(self._connection._shell, "_IS_WINDOWS", False):
|
||||
# This won't work on Powershell as-is, so we'll just completely skip until
|
||||
# we have a need for it, at which point we'll have to do something different.
|
||||
return remote_paths
|
||||
|
|
|
@ -65,11 +65,11 @@ class ActionModule(ActionBase):
|
|||
chdir = self._task.args.get('chdir')
|
||||
if chdir:
|
||||
# Powershell is the only Windows-path aware shell
|
||||
if self._connection._shell.SHELL_FAMILY == 'powershell' and \
|
||||
if getattr(self._connection._shell, "_IS_WINDOWS", False) and \
|
||||
not self.windows_absolute_path_detection.match(chdir):
|
||||
raise AnsibleActionFail('chdir %s must be an absolute path for a Windows remote node' % chdir)
|
||||
# Every other shell is unix-path-aware.
|
||||
if self._connection._shell.SHELL_FAMILY != 'powershell' and not chdir.startswith('/'):
|
||||
if not getattr(self._connection._shell, "_IS_WINDOWS", False) and not chdir.startswith('/'):
|
||||
raise AnsibleActionFail('chdir %s must be an absolute path for a Unix-aware remote node' % chdir)
|
||||
|
||||
# Split out the script as the first item in raw_params using
|
||||
|
@ -126,7 +126,7 @@ class ActionModule(ActionBase):
|
|||
exec_data = None
|
||||
# PowerShell runs the script in a special wrapper to enable things
|
||||
# like become and environment args
|
||||
if self._connection._shell.SHELL_FAMILY == "powershell":
|
||||
if getattr(self._connection._shell, "_IS_WINDOWS", False):
|
||||
# FUTURE: use a more public method to get the exec payload
|
||||
pc = self._play_context
|
||||
exec_data = ps_manifest._create_powershell_wrapper(
|
||||
|
|
|
@ -86,7 +86,7 @@ class ActionModule(ActionBase):
|
|||
pass
|
||||
|
||||
# Use win_ping on winrm/powershell, else use ping
|
||||
if hasattr(self._connection, '_shell_type') and self._connection._shell_type == 'powershell':
|
||||
if getattr(self._connection._shell, "_IS_WINDOWS", False):
|
||||
ping_result = self._execute_module(module_name='win_ping', module_args=dict(), task_vars=task_vars)
|
||||
else:
|
||||
ping_result = self._execute_module(module_name='ping', module_args=dict(), task_vars=task_vars)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue