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/68298/head
Jordan Borean 5 years ago committed by Matt Martz
parent 2c7f8bf586
commit aaf575f0b2

@ -165,14 +165,21 @@ class ActionBase(with_metaclass(ABCMeta, object)):
# Check to determine if PowerShell modules are supported, and apply # Check to determine if PowerShell modules are supported, and apply
# some fixes (hacks) to module name + args. # some fixes (hacks) to module name + args.
if mod_type == '.ps1': 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 # python counterparts but they are compatible enough for our
# internal usage # internal usage
if module_name in ('stat', 'file', 'copy') and self._task.action != module_name: if module_name in ('stat', 'file', 'copy', 'ping') and self._task.action != module_name:
module_name = 'win_%s' % 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. # 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'): for key in ('src', 'dest', 'path'):
if key in module_args: if key in module_args:
module_args[key] = self._connection._shell._unquote(module_args[key]) module_args[key] = self._connection._shell._unquote(module_args[key])

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

@ -2,10 +2,6 @@
- name: collect the coverage files from the Windows host - name: collect the coverage files from the Windows host
hosts: windows hosts: windows
gather_facts: no 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: tasks:
- name: make sure all vars have been set - name: make sure all vars have been set
assert: assert:

Loading…
Cancel
Save