better handling of parsed
updated tests to match new result output
(cherry picked from commit 5e98be2e62
)
This commit is contained in:
parent
4f8a2d3806
commit
4e6cdf8989
2 changed files with 3 additions and 2 deletions
|
@ -742,7 +742,6 @@ class ActionBase(with_metaclass(ABCMeta, object)):
|
||||||
|
|
||||||
# remove internal keys
|
# remove internal keys
|
||||||
self._remove_internal_keys(data)
|
self._remove_internal_keys(data)
|
||||||
data['_ansible_parsed'] = True
|
|
||||||
|
|
||||||
# cleanup tmp?
|
# cleanup tmp?
|
||||||
if (self._play_context.become and self._play_context.become_user != 'root') and not persist_files and delete_remote_tmp or tmpdir_delete:
|
if (self._play_context.become and self._play_context.become_user != 'root') and not persist_files and delete_remote_tmp or tmpdir_delete:
|
||||||
|
@ -767,7 +766,7 @@ class ActionBase(with_metaclass(ABCMeta, object)):
|
||||||
|
|
||||||
def _remove_internal_keys(self, data):
|
def _remove_internal_keys(self, data):
|
||||||
for key in list(data.keys()):
|
for key in list(data.keys()):
|
||||||
if key.startswith('_ansible_') or key in C.INTERNAL_RESULT_KEYS:
|
if key.startswith('_ansible_') and key != '_ansible_parsed' or key in C.INTERNAL_RESULT_KEYS:
|
||||||
display.warning("Removed unexpected internal key in module return: %s = %s" % (key, data[key]))
|
display.warning("Removed unexpected internal key in module return: %s = %s" % (key, data[key]))
|
||||||
del data[key]
|
del data[key]
|
||||||
|
|
||||||
|
@ -824,6 +823,7 @@ class ActionBase(with_metaclass(ABCMeta, object)):
|
||||||
if 'ansible_facts' in data and isinstance(data['ansible_facts'], dict):
|
if 'ansible_facts' in data and isinstance(data['ansible_facts'], dict):
|
||||||
self._clean_returned_data(data['ansible_facts'])
|
self._clean_returned_data(data['ansible_facts'])
|
||||||
data['ansible_facts'] = wrap_var(data['ansible_facts'])
|
data['ansible_facts'] = wrap_var(data['ansible_facts'])
|
||||||
|
data['_ansible_parsed'] = True
|
||||||
except ValueError:
|
except ValueError:
|
||||||
# not valid json, lets try to capture error
|
# not valid json, lets try to capture error
|
||||||
data = dict(failed=True, _ansible_parsed=False)
|
data = dict(failed=True, _ansible_parsed=False)
|
||||||
|
|
|
@ -591,6 +591,7 @@ class TestActionBaseParseReturnedData(unittest.TestCase):
|
||||||
'stdout_lines': stdout.splitlines(),
|
'stdout_lines': stdout.splitlines(),
|
||||||
'stderr': err}
|
'stderr': err}
|
||||||
res = action_base._parse_returned_data(returned_data)
|
res = action_base._parse_returned_data(returned_data)
|
||||||
|
del res['_ansible_parsed'] # we always have _ansible_parsed
|
||||||
self.assertEqual(len(res), 0)
|
self.assertEqual(len(res), 0)
|
||||||
self.assertFalse(res)
|
self.assertFalse(res)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue