diff --git a/changelogs/fragments/fix_gathering_reporting.yml b/changelogs/fragments/fix_gathering_reporting.yml new file mode 100644 index 00000000000..da98bb68489 --- /dev/null +++ b/changelogs/fragments/fix_gathering_reporting.yml @@ -0,0 +1,2 @@ +bugfixes: + - gather_facts now correctly passes back the full output of modules on error and skipped, fixes #57204 diff --git a/lib/ansible/plugins/action/gather_facts.py b/lib/ansible/plugins/action/gather_facts.py index 872c497b6ca..f08cd0a8ab6 100644 --- a/lib/ansible/plugins/action/gather_facts.py +++ b/lib/ansible/plugins/action/gather_facts.py @@ -65,9 +65,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', {})}) @@ -87,9 +87,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] @@ -101,16 +101,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