Fix gather_facts error/skipped reporting (#58927)

now give back full output from each module executed
 fixes #57204
pull/58642/merge
Brian Coca 5 years ago committed by GitHub
parent 59feb63d19
commit adea964c3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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

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

Loading…
Cancel
Save