re-enable non-pipelined mode for Powershell (#25012)

* fixes #23986
* fixes 3rd-party Windows connection plugins that don't support pipelining (eg awsrun)
This commit is contained in:
Matt Davis
2017-06-26 22:58:09 -07:00
committed by GitHub
parent b41c42cf0d
commit 36ad934156
7 changed files with 128 additions and 121 deletions

View File

@@ -31,7 +31,7 @@ from abc import ABCMeta, abstractmethod
from ansible import constants as C
from ansible.errors import AnsibleError, AnsibleConnectionFailure, AnsibleActionSkip, AnsibleActionFail
from ansible.executor.module_common import modify_module, build_windows_module_payload
from ansible.executor.module_common import modify_module
from ansible.module_utils.json_utils import _filter_non_json_lines
from ansible.module_utils.six import binary_type, string_types, text_type, iteritems, with_metaclass
from ansible.module_utils.six.moves import shlex_quote
@@ -153,18 +153,15 @@ class ActionBase(with_metaclass(ABCMeta, object)):
"run 'git pull --rebase' to correct this problem." % (module_name))
# insert shared code and arguments into the module
(module_data, module_style, module_shebang) = modify_module(module_name, module_path, module_args,
task_vars=task_vars, module_compression=self._play_context.module_compression)
final_environment = dict()
self._compute_environment_string(final_environment)
# FUTURE: we'll have to get fancier about this to support powershell over SSH on Windows...
if self._connection.transport == "winrm":
# WinRM always pipelines, so we need to build up a fancier module payload...
final_environment = dict()
self._compute_environment_string(final_environment)
module_data = build_windows_module_payload(module_name=module_name, module_path=module_path,
b_module_data=module_data, module_args=module_args,
task_vars=task_vars, task=self._task,
play_context=self._play_context, environment=final_environment)
(module_data, module_style, module_shebang) = modify_module(module_name, module_path, module_args,
task_vars=task_vars, module_compression=self._play_context.module_compression,
async_timeout=self._task.async, become=self._play_context.become,
become_method=self._play_context.become_method, become_user=self._play_context.become_user,
become_password=self._play_context.become_pass,
environment=final_environment)
return (module_style, module_shebang, module_data, module_path)
@@ -184,7 +181,7 @@ class ActionBase(with_metaclass(ABCMeta, object)):
# block then task 'win' in precedence
environments.reverse()
for environment in environments:
if environment is None:
if environment is None or len(environment) == 0:
continue
temp_environment = self._templar.template(environment)
if not isinstance(temp_environment, dict):
@@ -193,7 +190,8 @@ class ActionBase(with_metaclass(ABCMeta, object)):
# these environment settings should not need to merge sub-dicts
final_environment.update(temp_environment)
final_environment = self._templar.template(final_environment)
if len(final_environment) > 0:
final_environment = self._templar.template(final_environment)
if isinstance(raw_environment_out, dict):
raw_environment_out.clear()
@@ -212,13 +210,11 @@ class ActionBase(with_metaclass(ABCMeta, object)):
'''
Determines if we are required and can do pipelining
'''
if self._connection.always_pipeline_modules:
return True # eg, winrm
# any of these require a true
for condition in [
self._connection.has_pipelining,
self._play_context.pipelining,
self._play_context.pipelining or self._connection.always_pipeline_modules, # pipelining enabled for play or connection requires it (eg winrm)
module_style == "new", # old style modules do not support pipelining
not C.DEFAULT_KEEP_REMOTE_FILES, # user wants remote files
not wrap_async, # async does not support pipelining