Fix gather_facts error/skipped reporting (#58927)

now give back full output from each module executed
 fixes #57204
This commit is contained in:
Brian Coca 2019-07-11 14:18:32 -04:00 committed by GitHub
parent 59feb63d19
commit adea964c3e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 8 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- gather_facts now correctly passes back the full output of modules on error and skipped, fixes #57204

View file

@ -69,9 +69,9 @@ class ActionModule(ActionBase):
mod_args = self._get_module_args(fact_module, task_vars)
res = self._execute_module(module_name=fact_module, module_args=mod_args, task_vars=task_vars, wrap_async=False)
if res.get('failed', False):
failed[fact_module] = res.get('msg')
failed[fact_module] = res
elif res.get('skipped', False):
skipped[fact_module] = res.get('msg')
skipped[fact_module] = res
else:
result = combine_vars(result, {'ansible_facts': res.get('ansible_facts', {})})
@ -91,9 +91,9 @@ class ActionModule(ActionBase):
res = self._execute_module(module_name='async_status', module_args=poll_args, task_vars=task_vars, wrap_async=False)
if res.get('finished', 0) == 1:
if res.get('failed', False):
failed[module] = res.get('msg')
failed[module] = res
elif res.get('skipped', False):
skipped[module] = res.get('msg')
skipped[module] = res
else:
result = combine_vars(result, {'ansible_facts': res.get('ansible_facts', {})})
del jobs[module]
@ -105,16 +105,14 @@ class ActionModule(ActionBase):
if skipped:
result['msg'] = "The following modules were skipped: %s\n" % (', '.join(skipped.keys()))
for skip in skipped:
result['msg'] += ' %s: %s\n' % (skip, skipped[skip])
result['skipped_modules'] = skipped
if len(skipped) == len(modules):
result['skipped'] = True
if failed:
result['failed'] = True
result['msg'] = "The following modules failed to execute: %s\n" % (', '.join(failed.keys()))
for fail in failed:
result['msg'] += ' %s: %s\n' % (fail, failed[fail])
result['failed_modules'] = failed
# tell executor facts were gathered
result['ansible_facts']['_ansible_facts_gathered'] = True