Internally redirect win modules to collection name (#68317)

* Internally redirect win modules to collection name

* Added comment for how this should be fixed in a subsystem plugin

* add collection plugins for base tests
pull/68377/head
Jordan Borean 5 years ago committed by GitHub
parent bbc4bdc21c
commit 9237c4f788
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -165,14 +165,21 @@ class ActionBase(with_metaclass(ABCMeta, object)):
# Check to determine if PowerShell modules are supported, and apply
# some fixes (hacks) to module name + args.
if mod_type == '.ps1':
# win_stat, win_file, and win_copy are not just like their
# FIXME: This should be temporary and moved to an exec subsystem plugin where we can define the mapping
# for each subsystem.
win_collection = 'ansible.windows'
# async_status, win_stat, win_file, win_copy, and win_ping are not just like their
# python counterparts but they are compatible enough for our
# internal usage
if module_name in ('stat', 'file', 'copy') and self._task.action != module_name:
module_name = 'win_%s' % module_name
if module_name in ('stat', 'file', 'copy', 'ping') and self._task.action != module_name:
module_name = '%s.win_%s' % (win_collection, module_name)
elif module_name in ['async_status']:
module_name = '%s.%s' % (win_collection, module_name)
# Remove extra quotes surrounding path parameters before sending to module.
if module_name in ('win_stat', 'win_file', 'win_copy', 'slurp') and module_args and hasattr(self._connection._shell, '_unquote'):
if module_name.split('.')[-1] in ['win_stat', 'win_file', 'win_copy', 'slurp'] and module_args and \
hasattr(self._connection._shell, '_unquote'):
for key in ('src', 'dest', 'path'):
if key in module_args:
module_args[key] = self._connection._shell._unquote(module_args[key])

@ -88,11 +88,7 @@ class ActionModule(ActionBase):
except AttributeError:
pass
# Use win_ping on winrm/powershell, else use ping
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)
ping_result = self._execute_module(module_name='ping', module_args=dict(), task_vars=task_vars)
# Test module output
if ping_result['ping'] != 'pong':

@ -2,10 +2,6 @@
- name: collect the coverage files from the Windows host
hosts: windows
gather_facts: no
# The collections keyword is required to allow fetch to work.
# See: https://github.com/ansible/ansible/issues/68269
collections:
- ansible.windows
tasks:
- name: make sure all vars have been set
assert:

Loading…
Cancel
Save