Handle gracefully a bad module 'results' key (#53973)
* Handle gracefully a bad module 'results' key fixes #53962
This commit is contained in:
parent
09cd355bec
commit
3637ce4538
2 changed files with 9 additions and 0 deletions
2
changelogs/fragments/clean_results.yml
Normal file
2
changelogs/fragments/clean_results.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- disallow non dict results from module and allow user to continue using with a warning.
|
|
@ -21,6 +21,7 @@ from ansible import constants as C
|
|||
from ansible.errors import AnsibleError, AnsibleConnectionFailure, AnsibleActionSkip, AnsibleActionFail
|
||||
from ansible.executor.module_common import modify_module
|
||||
from ansible.executor.interpreter_discovery import discover_interpreter, InterpreterDiscoveryRequiredError
|
||||
from ansible.module_utils.common._collections_compat import Sequence
|
||||
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
|
||||
|
@ -909,6 +910,12 @@ class ActionBase(with_metaclass(ABCMeta, object)):
|
|||
if data.pop("_ansible_suppress_tmpdir_delete", False):
|
||||
self._cleanup_remote_tmp = False
|
||||
|
||||
# NOTE: yum returns results .. but that made it 'compatible' with squashing, so we allow mappings, for now
|
||||
if 'results' in data and (not isinstance(data['results'], Sequence) or isinstance(data['results'], string_types)):
|
||||
data['ansible_module_results'] = data['results']
|
||||
del data['results']
|
||||
display.warning("Found internal 'results' key in module return, renamed to 'ansible_module_results'.")
|
||||
|
||||
# remove internal keys
|
||||
remove_internal_keys(data)
|
||||
|
||||
|
|
Loading…
Reference in a new issue